-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CodeKevin
committed
Mar 15, 2015
1 parent
eced601
commit d09d0a9
Showing
7 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import hashlib | ||
import digitalocean | ||
import shutil | ||
import requests | ||
|
||
|
||
def init_utils(app): | ||
|
@@ -147,18 +148,31 @@ def set_config(key, value): | |
|
||
|
||
def mailserver(): | ||
if app.config['MAIL_SERVER'] and app.config['MAIL_PORT'] and app.config['ADMINS']: | ||
if get_config('mg_api_key') or (app.config['MAIL_SERVER'] and app.config['MAIL_PORT'] and app.config['ADMINS']): | ||
return True | ||
return False | ||
|
||
|
||
def sendmail(addr, text): | ||
try: | ||
msg = Message("Message from {0}".format(app.config['CTF_NAME']), sender = app.config['ADMINS'][0], recipients = [addr]) | ||
msg.body = text | ||
mail.send(msg) | ||
return True | ||
except: | ||
if get_config('mg_api_key'): | ||
ctf_name = get_config('ctf_name') | ||
mg_api_key = get_config('mg_api_key') | ||
return requests.post( | ||
"https://api.mailgun.net/v2/mail"+app.config['HOST']+"/messages", | ||
auth=("api", mg_api_key), | ||
data={"from": "{} Admin <[email protected]>".format(ctf_name), | ||
"to": [addr], | ||
"subject": "Message from {0}".format(ctf_name), | ||
"text": text}) | ||
elif app.config['MAIL_SERVER'] and app.config['MAIL_PORT'] and app.config['ADMINS']: | ||
try: | ||
msg = Message("Message from {0}".format(get_config('ctf_name')), sender=app.config['ADMINS'][0], recipients=[addr]) | ||
msg.body = text | ||
mail.send(msg) | ||
return True | ||
except: | ||
return False | ||
else: | ||
return False | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ passlib==1.6.2 | |
bcrypt | ||
six==1.8.0 | ||
itsdangerous | ||
python-digitalocean | ||
python-digitalocean | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters