mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-01-10 09:34:20 +01:00
Add the ability to override the sender header of email via SMTP (#1657)
* Add the ability to override the sender header of email via SMTP with the `MAILSENDER_ADDR` config value * Closes #1644
This commit is contained in:
@@ -56,7 +56,15 @@ def sendmail(addr, text, subject):
|
||||
msg["From"] = mailfrom_addr
|
||||
msg["To"] = addr
|
||||
|
||||
smtp.send_message(msg)
|
||||
# Check whether we are using an admin-defined SMTP server
|
||||
custom_smtp = bool(get_config("mail_server"))
|
||||
|
||||
# We should only consider the MAILSENDER_ADDR value on servers defined in config
|
||||
if custom_smtp:
|
||||
smtp.send_message(msg)
|
||||
else:
|
||||
mailsender_addr = get_app_config("MAILSENDER_ADDR")
|
||||
smtp.send_message(msg, from_addr=mailsender_addr)
|
||||
|
||||
smtp.quit()
|
||||
return True, "Email sent"
|
||||
|
||||
Reference in New Issue
Block a user