修改CTFd使其支持发送HTML邮件

h3110w0r1d
2020-08-15 / 0 评论 / 560 阅读 / 正在检测是否收录...

修改文件CTFd/CTFd/utils/email/smtp.py
添加代码

from email.header import Header
from email.mime.text import MIMEText

修改smtp = get_smtp(**data)后面的代码

#        msg = EmailMessage()
#        msg.set_content(text)
#
#        msg["Subject"] = subject
#        msg["From"] = mailfrom_addr
#        msg["To"] = addr
#
#        smtp.send_message(msg)

        msg = MIMEText(text, 'html', 'utf-8')
        msg['Subject'] = Header(subject, 'utf-8')
        msg['From'] = mailfrom_addr
        msg['To'] = addr
        
        smtp.sendmail(mailfrom_addr, addr, msg.as_string())
77

评论 (0)

取消