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:
Kevin Chung
2020-09-20 23:54:19 -04:00
committed by GitHub
parent 1be3659996
commit 4cd4d0cb92
3 changed files with 19 additions and 1 deletions

View File

@@ -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"