1
我試圖發送使用Python的電子郵件,並使用下面的代碼:發送使用smtpd.DebuggingServer作爲STMP服務器從蟒蛇的電子郵件
import smtplib
import datetime
SERVER = "localhost"
PORT = 1025
FROM = "[email protected]"
TO = ["[email protected]"]
SUBJECT = "test"
dt = datetime.datetime.now()
TEXT = "blabla bla @ " + str(dt)
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ",".join(TO), SUBJECT, TEXT)
server = smtplib.SMTP(SERVER,PORT)
server.sendmail(FROM,TO,message)
server.quit()
沒有任何STMP服務器已經安裝/設置,我只是用這個:
python -m smtpd -n -c DebuggingServer localhost:1025
代碼看上去一切正常,沒有錯誤,服務器甚至通知我這件事:
---------- MESSAGE FOLLOWS ----------
From: [email protected]
To: [email protected]
Subject: test
X-Peer: 127.0.0.1
blabla bla @ 2014-01-29 14:44:37.219724
------------ END MESSAGE ------------
'[email protected]'當然是一個真實的現有電子郵件地址的表示,而'[email protected]'是由這個地址組成的。
但沒有電子郵件到達[email protected] ...
我失去的東西在這裏很明顯?
我在某處閱讀(抱歉,但無法找到它)服務喜歡Gmail可能會阻止來自非靜態IP地址的電子郵件。這可能是這裏發生了什麼?
不知道去哪裏找......
感謝 大衛