Fix sending emails when CTF name contains colons (#1560)

* Fixes issue with sending emails if the CTF name has a colon
* Closes #1558
This commit is contained in:
Kevin Chung
2020-07-21 19:53:28 -04:00
committed by GitHub
parent 5cbab768db
commit 98b9dda58c
2 changed files with 5 additions and 2 deletions

View File

@@ -1,3 +1,5 @@
from email.utils import formataddr
import requests
from CTFd.utils import get_app_config, get_config
@@ -6,7 +8,7 @@ from CTFd.utils import get_app_config, get_config
def sendmail(addr, text, subject):
ctf_name = get_config("ctf_name")
mailfrom_addr = get_config("mailfrom_addr") or get_app_config("MAILFROM_ADDR")
mailfrom_addr = "{} <{}>".format(ctf_name, mailfrom_addr)
mailfrom_addr = formataddr((ctf_name, mailfrom_addr))
mailgun_base_url = get_config("mailgun_base_url") or get_app_config(
"MAILGUN_BASE_URL"

View File

@@ -1,5 +1,6 @@
import smtplib
from email.message import EmailMessage
from email.utils import formataddr
from socket import timeout
from CTFd.utils import get_app_config, get_config
@@ -22,7 +23,7 @@ def get_smtp(host, port, username=None, password=None, TLS=None, SSL=None, auth=
def sendmail(addr, text, subject):
ctf_name = get_config("ctf_name")
mailfrom_addr = get_config("mailfrom_addr") or get_app_config("MAILFROM_ADDR")
mailfrom_addr = "{} <{}>".format(ctf_name, mailfrom_addr)
mailfrom_addr = formataddr((ctf_name, mailfrom_addr))
data = {
"host": get_config("mail_server") or get_app_config("MAIL_SERVER"),