mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-20 07:14:24 +01:00
Changed to dyniamic argument of mail function (#170)
This commit is contained in:
@@ -363,11 +363,12 @@ def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None):
|
|||||||
|
|
||||||
|
|
||||||
def sendmail(addr, text):
|
def sendmail(addr, text):
|
||||||
if mailgun():
|
|
||||||
ctf_name = get_config('ctf_name')
|
ctf_name = get_config('ctf_name')
|
||||||
|
mailfrom_addr = get_config('mailfrom_addr') or app.config.get('MAILFROM_ADDR')
|
||||||
|
if mailgun():
|
||||||
mg_api_key = get_config('mg_api_key') or app.config.get('MAILGUN_API_KEY')
|
mg_api_key = get_config('mg_api_key') or app.config.get('MAILGUN_API_KEY')
|
||||||
mg_base_url = get_config('mg_base_url') or app.config.get('MAILGUN_BASE_URL')
|
mg_base_url = get_config('mg_base_url') or app.config.get('MAILGUN_BASE_URL')
|
||||||
mailfrom_addr = get_config('mailfrom_addr') or app.config.get('MAILFROM_ADDR')
|
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
mg_base_url + '/messages',
|
mg_base_url + '/messages',
|
||||||
auth=("api", mg_api_key),
|
auth=("api", mg_api_key),
|
||||||
@@ -395,8 +396,8 @@ def sendmail(addr, text):
|
|||||||
|
|
||||||
smtp = get_smtp(**data)
|
smtp = get_smtp(**data)
|
||||||
msg = email.mime.text.MIMEText(text)
|
msg = email.mime.text.MIMEText(text)
|
||||||
msg['Subject'] = "Message from {0}".format(get_config('ctf_name'))
|
msg['Subject'] = "Message from {0}".format(ctf_name)
|
||||||
msg['From'] = 'noreply@ctfd.io'
|
msg['From'] = mailfrom_addr
|
||||||
msg['To'] = addr
|
msg['To'] = addr
|
||||||
|
|
||||||
smtp.sendmail(msg['From'], [msg['To']], msg.as_string())
|
smtp.sendmail(msg['From'], [msg['To']], msg.as_string())
|
||||||
|
|||||||
Reference in New Issue
Block a user