From 0f5cc535b7aff4f66b2ef8b2fa564fc098b631b3 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Thu, 1 Jun 2017 16:40:29 +0200 Subject: [PATCH] Avoid reading undefined senderrs variable when sendmail fails issue6535 review41341003 --- trytond/sendmail.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/trytond/sendmail.py b/trytond/sendmail.py index cdc5d6ef28..4a2a2dbc0d 100644 --- a/trytond/sendmail.py +++ b/trytond/sendmail.py @@ -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()