我使用下面的腳本向我發送電子郵件,腳本運行正常,沒有錯誤,但我實際上沒有收到電子郵件。Python:電子郵件問題
import smtplib
sender = '[email protected]'
receivers = ['[email protected]']
message = """From: From Person <[email protected]>
To: To Person <[email protected]>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"
編輯
腳本就是爲什麼你使用localhost作爲SMTP命名爲test.py
如果我身體收到了一封電子郵件,我得有與我的談話縮水。 – 2010-07-27 19:09:29