Merge pull request #495 from flortsch/master

Properly handle to field in mail notifications when using uWSGI spooler.
This commit is contained in:
Jelmer Vernooij 2018-11-06 21:00:33 +00:00 committed by GitHub
commit 1d16db53da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,7 +91,8 @@ class SMTP(object):
def spooler(args):
try:
self._sendmail(args[b"subject"].decode("utf-8"),
args["body"].decode("utf-8"))
args["body"].decode("utf-8"),
args[b"to"].decode("utf-8"))
except smtplib.SMTPConnectError:
return uwsgi.SPOOL_RETRY
else:
@ -173,17 +174,17 @@ class SMTP(object):
notified.append(email)
def sendmail(self, subject, body, thread, comment, to=None):
to = to or self.conf.get("to")
if uwsgi:
uwsgi.spool({b"subject": subject.encode("utf-8"),
b"body": body.encode("utf-8"),
b"to": to})
b"to": to.encode("utf-8")})
else:
start_new_thread(self._retry, (subject, body, to))
def _sendmail(self, subject, body, to=None):
def _sendmail(self, subject, body, to_addr):
from_addr = self.conf.get("from")
to_addr = to or self.conf.get("to")
msg = MIMEText(body, 'plain', 'utf-8')
msg['From'] = from_addr