diff options
-rw-r--r-- | utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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() |