我嘗試通過python發送郵件。 根據我的腳本發送是成功的。用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('127.0.0.1', 1025)
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except smtplib.SMTPException:
print "Error: unable to send email"
但是,當我檢查我的電子郵件,我沒有新的郵件。 :( 問題出在哪里哪里是我發送的電子郵件
編輯:??
我的SMTP測試服務器爲:
import smtpd
import asyncore
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
return
server = CustomSMTPServer(('127.0.0.1', 1025), None)
print "Started...."
asyncore.loop()
我的SMTP服務器說:
Receiving message from: ('127.0.0.1', 65071)
Message addressed from: [email protected]
Message addressed to : ['[email protected]']
Message length : 129
本地主機上的SMTP服務器是否工作?你檢查過垃圾郵件文件夾嗎? – 2012-09-27 10:30:05
你有'.login'嗎? –
本地主機上的端口1025上運行什麼?它有一個日誌文件嗎? – tripleee