【发布时间】:2015-08-27 01:25:31
【问题描述】:
我有一个来自here 的简单 SMTP 邮件示例,我对其进行了修改。我的代码是:
import smtplib
sender = 'igor.savinkin@gmail.com'
receivers = ['igor.savinkin@gmail.com']
message = """From: From Igor <igor.savinkin@gmail.com>
To: To Igor Savinkin <igor.savinkin@gmail.com>
Subject: SMTP e-mail test
This is a test e-mail message from SMTP python.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email to " + receivers.__str__()
except SMTPException:
print "Error: unable to send email"
输出是:
已成功发送电子邮件至 ['igor.savinkin@gmail.com']
然而,实际上我在收件箱中没有找到类似的邮件。垃圾邮件文件夹也被检查了! 怎么了?我使用 rhc (OpenShift) 平台。
【问题讨论】:
-
它在普通的 linux 服务器上为我工作
-
由于您使用的是更受限制的环境(openshift),可能 smtp 端口 25 被阻止。检查 iptables。
-
我使用了
except Exception,e:并打印出来。显示[Errno 10061] No connection could be made because the target machine actively refused it我的是一台windows 机器 -
@duck,我在哪里/如何检查 iptables?
-
我进行了更多搜索并成功通过Gmail help发送邮件