from/sender nun getrennt

alle Mails kommen von "admin_address" (falls definiert)
This commit is contained in:
lars 2012-08-23 23:07:59 +00:00
parent cec69f8846
commit 9266f5c789

View file

@ -150,11 +150,13 @@ def get_session(session_id):
return session
def send_mail(to_address, from_address, subject, text):
def send_mail(to_address, from_address, subject, text, sender=None):
msg = email.mime.text.MIMEText(unicode(text), _charset="utf-8")
msg["Subject"] = unicode(subject)
msg["From"] = from_address
msg["To"] = to_address
if sender:
msg["Sender"] = sender
msg["Date"] = email.utils.formatdate()
use_ssl = config.get("mail", "use_ssl", "no")
use_ssl = use_ssl.lower() in ("1", "true", "yes", "on", "enabled")
@ -210,12 +212,12 @@ def do_submit(session_id=None, subject=None, from_address=None,
if params["errors"]:
return render("summary.html", input_data=input_data, **params)
else:
admin_address = config.get("mail", "admin_address", "")
try:
send_mail(to_address, from_address, subject, summary_text)
send_mail(to_address, admin_address or from_address, subject, summary_text, sender=from_address)
except smtplib.SMTPException, err_msg:
params["errors"] = "Der Versand der Mail schlug fehl: %s" % err_msg
return render("summary.html", input_data=input_data, **params)
admin_address = config.get("mail", "admin_address", "")
try:
if admin_address:
send_mail(from_address, admin_address, subject, summary_text)