from/sender nun getrennt
alle Mails kommen von "admin_address" (falls definiert)
This commit is contained in:
parent
cec69f8846
commit
9266f5c789
1 changed files with 5 additions and 3 deletions
|
@ -150,11 +150,13 @@ def get_session(session_id):
|
||||||
return session
|
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 = email.mime.text.MIMEText(unicode(text), _charset="utf-8")
|
||||||
msg["Subject"] = unicode(subject)
|
msg["Subject"] = unicode(subject)
|
||||||
msg["From"] = from_address
|
msg["From"] = from_address
|
||||||
msg["To"] = to_address
|
msg["To"] = to_address
|
||||||
|
if sender:
|
||||||
|
msg["Sender"] = sender
|
||||||
msg["Date"] = email.utils.formatdate()
|
msg["Date"] = email.utils.formatdate()
|
||||||
use_ssl = config.get("mail", "use_ssl", "no")
|
use_ssl = config.get("mail", "use_ssl", "no")
|
||||||
use_ssl = use_ssl.lower() in ("1", "true", "yes", "on", "enabled")
|
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"]:
|
if params["errors"]:
|
||||||
return render("summary.html", input_data=input_data, **params)
|
return render("summary.html", input_data=input_data, **params)
|
||||||
else:
|
else:
|
||||||
|
admin_address = config.get("mail", "admin_address", "")
|
||||||
try:
|
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:
|
except smtplib.SMTPException, err_msg:
|
||||||
params["errors"] = "Der Versand der Mail schlug fehl: %s" % err_msg
|
params["errors"] = "Der Versand der Mail schlug fehl: %s" % err_msg
|
||||||
return render("summary.html", input_data=input_data, **params)
|
return render("summary.html", input_data=input_data, **params)
|
||||||
admin_address = config.get("mail", "admin_address", "")
|
|
||||||
try:
|
try:
|
||||||
if admin_address:
|
if admin_address:
|
||||||
send_mail(from_address, admin_address, subject, summary_text)
|
send_mail(from_address, admin_address, subject, summary_text)
|
||||||
|
|
Loading…
Reference in a new issue