Hi,
I have a internet connection at home. I have installed Python2.6.1 on my laptop in C:\Python26 directory. I have written a script named "TestUtil_SendMail.py" and my intension is to send a mail to the given mail id.
But when am running the script I am getting an error: "[Errno 10061] No connection could be made because the target machine actively refused it". Kindly help me resolve this issue.
TestUtil_SendMail.py:
import smtplib
print "EMAIL UTILITY!!!!!!!!!!!!!!!!!"
SERVER = "localhost"
FROM = "xyz@gmail.com"
TO = ["xyz@gmail.com"] # must be a list
SUBJECT = "Hello!"
TEXT = "This message was sent with Python's smtplib."
# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s
%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)
# Send the mail
server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()
print "Mail has been sent... Thanks"
--------------------------------------------------------------------
But while running I am getting the following Error:
>>>
EMAIL UTILITY!!!!!!!!!!!!!!!!!
Traceback (most recent call last):
File "C:/Python26/TestUtil_SendMail.py", line 25, in <module>
server = smtplib.SMTP(SERVER)
File "C:\Python26\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "C:\Python26\lib\smtplib.py", line 295, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "C:\Python26\lib\smtplib.py", line 273, in _get_socket
return socket.create_connection((port, host), timeout)
File "C:\Python26\lib\socket.py", line 512, in create_connection
raise error, msg
error: [Errno 10061] No connection could be made because the target machine actively refused it
>>>
------------------------------------------------------------------------------
Thanks,
Shakila.