From 594713cf80890a9b96a9284b417a7504d7e3f137 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Fri, 10 Jan 2014 02:14:09 +0100 Subject: utils: also set envelop sender for mails --- utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 478c034..28b5207 100644 --- a/utils.py +++ b/utils.py @@ -8,6 +8,7 @@ import subprocess from base64 import urlsafe_b64encode, urlsafe_b64decode from Crypto.Cipher import AES from email.mime.text import MIMEText +from email.utils import parseaddr from functools import wraps from flask import current_app, flash, g, redirect, render_template, request, session from flask import url_for as flask_url_for @@ -205,7 +206,12 @@ def send_mail(recipient, subject, body, sender=None): msg['To'] = safe(recipient) msg['From'] = safe(sender) - p = subprocess.Popen([current_app.config['SENDMAIL_COMMAND'], '-t'], + envelope = [] + (name, address) = parseaddr(safe(sender)) + if address != '': + envelope = ['-f', address] + + p = subprocess.Popen([current_app.config['SENDMAIL_COMMAND']] + envelope + ['-t'], stdin=subprocess.PIPE) p.stdin.write(msg.as_string()) p.stdin.close() -- cgit v1.2.3-1-g7c22