smtplib.SMTPAuthenticationError: (535, '5.7.3 身份验证不成功') [英] smtplib.SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful')
问题描述
我正在尝试使用 smtplib 在 python 2.7 中发送邮件.下面的代码非常简单:
I am trying to use smtplib for sending mails in python 2.7. The below code is pretty simple:
import smtplib
def main(argv=None):
sender = 'abc@gmail.com'
receivers = ['xyz@gmail.com']
message = """
This is a test e-mail message.
"""
smtpObj = smtplib.SMTP('xyz@gmail.com',25)
smtpObj.login('abc', 'pwd')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
if __name__ == '__main__':
main()
现在,当我执行以下代码时,我不断收到此异常:
Now when I execute the below code, I keep getting this exception:
smtplib.SMTPAuthenticationError: (535, '5.7.3 身份验证不成功').
smtplib.SMTPAuthenticationError: (535, '5.7.3 Authentication unsuccessful').
请多多指教.
谢谢,
推荐答案
其实,当我尝试在 python 控制台上执行相同的语句时,我才知道密码不正确,这是由于字符编码不同造成的.
Actually, when I tried executing the same statements on python console, I came to know that the password was incorrect and it was due to different character encoding.
>
对于所有其他用户,不要复制粘贴
For all other users, refrain yourself from copy paste
这篇关于smtplib.SMTPAuthenticationError: (535, '5.7.3 身份验证不成功')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!