summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils.py8
1 files changed, 7 insertions, 1 deletions
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()