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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.