我正在尝试在 python 中制作电子邮件脚本。这是我所拥有的(来自 pythonlibrary.org):
#! /usr/bin/env python
import smtplib
import string
SUBJECT = "An email!"
TO = "me@icloud.com"
FROM = "me@gmail.com"
text = "This text is the contents of an email!"
BODY = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT ,
"",
text
), "\r\n")
server = smtplib.SMTP('smtp.gmail.com')
server.login('me@gmail.com', 'mypassword') # Not very secure, I know, but this email is dedicated to this script
server.sendmail(FROM, [TO], BODY)
server.quit()
我得到smtplib.SMTPException: SMTP AUTH extension not supported by server.
是这样的,那么为什么 smtp.gmail.com 完全响应?这是 Gmail 的问题,还是我的脚本或其他问题?
错误信息:
Traceback (most recent call last):
File "/Users/student/Desktop/mail.py", line 18, in <module>
server.login('*******@gmail.com', '**************')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/smtplib.py", line 552, in login
smtplib.SMTPException: SMTP AUTH extension not supported by server.