【发布时间】:2020-02-28 12:02:46
【问题描述】:
我想从本地 smtp 服务器向用户发送一条简单的短信。当我使用以下代码时,我收到以下错误
#!/usr/bin/python
import smtplib
receivers = ['to@todomain.com']
message = "hello"
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"
我收到以下错误:
[WinError 10061] No connection could be made because the target machine actively refused it
如何解决此错误。
【问题讨论】:
-
@Ananth.P 我试过了,但我不想使用任何来自地址只需发送一个简单的文本
标签: python-3.x smtp