Avoid reading undefined senderrs variable when sendmail fails

issue6535
review41341003
This commit is contained in:
Sergi Almacellas Abellana
2017-06-01 16:40:29 +02:00
parent aff8847db4
commit 0f5cc535b7
+3 -2
View File
@@ -33,8 +33,9 @@ def sendmail(from_addr, to_addrs, msg, server=None):
senderrs = server.sendmail(from_addr, to_addrs, msg.as_string())
except smtplib.SMTPException:
logger.error('fail to send email', exc_info=True)
if senderrs:
logger.warn('fail to send email to %s', senderrs)
else:
if senderrs:
logger.warn('fail to send email to %s', senderrs)
if quit:
server.quit()