smtplib.SMTPAuthenticationError

smtplib 连接mail 服务发邮件报以下错误

smtplib.SMTPAuthenticationError: (535, 'authorization failed (#5.7.0)')

解决:

s = smtplib.SMTP("localhost")
s.ehlo()
s.esmtp_features["auth"] = "LOGIN PLAIN"   # 关键的一句 
s.debuglevel = 5
s.login("...", "...")