From a7079bc7648efc139277cd527e5061a592a945db Mon Sep 17 00:00:00 2001 From: Nando Florestan Date: Thu, 25 Mar 2021 00:15:40 +0100 Subject: [PATCH] Stop swallowing dict returned by stdlib sendmail() --- repoze/sendmail/mailer.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/repoze/sendmail/mailer.py b/repoze/sendmail/mailer.py index 1bbb739..9078378 100644 --- a/repoze/sendmail/mailer.py +++ b/repoze/sendmail/mailer.py @@ -97,12 +97,15 @@ def send(self, fromaddr, toaddrs, message): 'Mailhost does not support ESMTP but a username ' 'is configured') - connection.sendmail(fromaddr, toaddrs, message) + # With multiple recipients sendmail() returns a dict that may + # contain an error for each recipient. + error_dict = connection.sendmail(fromaddr, toaddrs, message) try: connection.quit() except SSLError: - # something weird happened while quiting + # Something weird happened while quitting. connection.close() + return error_dict @implementer(IMailer) @@ -189,4 +192,4 @@ def _popen(self, *args, **kw): # pragma NO COVER Expects the same call signature as subprocess.Popen. """ kw['stdin'] = subprocess.PIPE - return subprocess.Popen(*args, **kw) + return subprocess.Popen(*args, **kw)