0

Hi,
I have tried to send email through python code the code is -

import smtplib
from email.MIMEText import MIMEText

#try:
s = smtplib.SMTP()
s.connect('') # I have given server name of email

s.sendmail("","","test") # i have given from user and send user
print "Succesfull"
s.quit()
#except:
# print "Error in sending mail to receiver:"

But when i execute this script then it gives following error-

Traceback (most recent call last):
File "<pyshell#121>", line 1, in <module>
reload (mail)
File "D:\Pankaj\python\mail.py", line 6, in <module>
s.connect()
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

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by jcao219
0

Have you tried using the telnet client for windows or whatever it is for linux? I suggest you try using that before you start that with python, it'll help you immensely.

0

Hi,

error: [Errno 10061] No connection could be made because the target machine actively refused it

I recognize that error.
I had it before when I was making an internet chat client in IronPython.
It happens when the server is behind a firewall or something.

It happened to me because I was testing the chat client, and it turned out that my router had DMZ set to something, and I had to turn it off so that the server received the info.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.