Commit e5c1f5d3 authored by Gero Müller's avatar Gero Müller
Browse files

fix mail sending

(transplanted from f2e0374024d9d85f77cacb58c8a0b9029ed1ac1c)
parent 2d788e8a
...@@ -298,6 +298,13 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None, ...@@ -298,6 +298,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. 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 # Header class is smart enough to try US-ASCII, then the charset we
# provide, then fall back to UTF-8. # provide, then fall back to UTF-8.
header_charset = 'ISO-8859-1' header_charset = 'ISO-8859-1'
...@@ -331,7 +338,7 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None, ...@@ -331,7 +338,7 @@ def send_mail(addr, subject="", content="", sender_addr=None, smtp_host=None,
msg['Subject'] = Header(unicode(subject), header_charset) msg['Subject'] = Header(unicode(subject), header_charset)
# Send the message via SMTP to localhost:25 # 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.sendmail(sender_addr, addr, msg.as_string())
smtp.quit() smtp.quit()
......
Supports Markdown
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