I want to send a simple text message to the user from local smtp server. When i am using the following code i am getting the following error
#!/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"
i am getting the following error:
[WinError 10061] No connection could be made because the target machine actively refused it
How to resolve this error.