def test_authentication(self):
"""
Check to see whether or not the currently configured SMTP credentials can be used
to authenticate to the remote service.
:return: True if the current configured SMTP credentials can be used to authenticate to
the remote service, False otherwise.
"""
connection = smtplib.SMTP(config.smtp_host, config.smtp_port)
connection.ehlo()
connection.starttls()
try:
connection.login(config.smtp_username, config.smtp_password)
return True
except smtplib.SMTPAuthenticationError:
return False
评论列表
文章目录