我尝试使用我的 python 脚本发送电子邮件,但收到错误消息:
5.7.0 must issue a starttls command first
我正在使用smtplib
,这是我的代码:
import smtplib
sender = 'from@fromdomain.com'
receivers = 'to@todomain.com'
message = """From: From Person <from@fromdomain.com>
To: To Person <to@todomain.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('smtp.gmail.com')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except Exception,e:
print str(e)
如果有人知道如何解决此错误,我将不胜感激。