Commit 190ed00d authored by Gero Müller's avatar Gero Müller

fix mail sending

parent 652880c7
......@@ -271,6 +271,13 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None,
and UTF-8 that can represent all the characters occurring in the email.
"""
if smtp_host is None:
smtp_host = config("mail", "smtp.host", "localhost")
if smtp_port is None:
smtp_host = config("mail", "smtp.port", 0)
if sender_addr is None:
sender_addr = config("mail", "sender_address", "noreply@example.org")
# Header class is smart enough to try US-ASCII, then the charset we
# provide, then fall back to UTF-8.
header_charset = 'ISO-8859-1'
......@@ -304,7 +311,7 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None,
msg['Subject'] = Header(unicode(subject), header_charset)
# Send the message via SMTP to localhost:25
smtp = SMTP("localhost")
smtp = SMTP(smtp_host, smtp_port)
smtp.sendmail(sender_addr, addr, msg.as_string())
smtp.quit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment