try:
if not self.check_smtp_connected("main", self.sender_addr):
self.close("main", self.sender_addr)
if not self.connect("main", self.sender_addr):
self.last_error = "req_id:%d,connect to %s main failed" % (mail_id, self.name)
raise Exception("req_id:%d,connect to %s main failed" % (mail_id, self.name))
sender_addr = parseaddr(self.msg['From'])[1]
recv_addr = parseaddr(self.msg['To'])[1]
self.smtp_conns[self.sender_addr].sendmail(self.msg['From'], self.msg['To'], self.msg.as_string())
except Exception as e:
glogger.warning("req_id:%d,send mail by %s failed, error: %s" % (mail_id, self.name, str(e)))
else:
sent_succ = True
break
check_smtp_connected use noop()[0] to check connection to smtp server.
the first time I get : req_id:7066283,send mail by tx_smtp failed, error: timed out
so the exception is time out and then I use check_smtp_connected to check the connection, it's broken.
the second time I get: req_id:7066283,send mail by tx_smtp failed, error: (250, 'Ok') so the exception is (250, 'Ok')
I read source code of sendmail, but can't find the branch that will raise this exception.
so I'm heavily puzzled. and the result is my mailbox get two mail