def _connect(self, host, port, retry_interval=60.0):
server = None
while server is None:
self.log.info(u"Connecting to SMTP server {0!r} port {1}".format(host, port))
try:
server = yield idiokit.thread(
SMTP, host, port,
ca_certs=self.smtp_ca_certs,
timeout=self.smtp_connection_timeout
)
except (socket.error, smtplib.SMTPException) as exc:
self.log.error(u"Failed connecting to SMTP server: {0}".format(utils.format_exception(exc)))
else:
self.log.info(u"Connected to the SMTP server")
break
self.log.info(u"Retrying SMTP connection in {0:.2f} seconds".format(retry_interval))
yield idiokit.sleep(retry_interval)
idiokit.stop(server)
评论列表
文章目录