Merge pull request #495 from flortsch/master
Properly handle to field in mail notifications when using uWSGI spooler.
This commit is contained in:
commit
1d16db53da
@ -91,7 +91,8 @@ class SMTP(object):
|
|||||||
def spooler(args):
|
def spooler(args):
|
||||||
try:
|
try:
|
||||||
self._sendmail(args[b"subject"].decode("utf-8"),
|
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:
|
except smtplib.SMTPConnectError:
|
||||||
return uwsgi.SPOOL_RETRY
|
return uwsgi.SPOOL_RETRY
|
||||||
else:
|
else:
|
||||||
@ -173,17 +174,17 @@ class SMTP(object):
|
|||||||
notified.append(email)
|
notified.append(email)
|
||||||
|
|
||||||
def sendmail(self, subject, body, thread, comment, to=None):
|
def sendmail(self, subject, body, thread, comment, to=None):
|
||||||
|
to = to or self.conf.get("to")
|
||||||
if uwsgi:
|
if uwsgi:
|
||||||
uwsgi.spool({b"subject": subject.encode("utf-8"),
|
uwsgi.spool({b"subject": subject.encode("utf-8"),
|
||||||
b"body": body.encode("utf-8"),
|
b"body": body.encode("utf-8"),
|
||||||
b"to": to})
|
b"to": to.encode("utf-8")})
|
||||||
else:
|
else:
|
||||||
start_new_thread(self._retry, (subject, body, to))
|
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")
|
from_addr = self.conf.get("from")
|
||||||
to_addr = to or self.conf.get("to")
|
|
||||||
|
|
||||||
msg = MIMEText(body, 'plain', 'utf-8')
|
msg = MIMEText(body, 'plain', 'utf-8')
|
||||||
msg['From'] = from_addr
|
msg['From'] = from_addr
|
||||||
|
Loading…
Reference in New Issue
Block a user