Marco Petersen wrote:
I'm using Python 2.5.4. I wanted to try out the SMTP module. I tried to send an email through my Gmail account but it keeps saying that the connection was refused.This is the code that I used : import smtplib msg = 'Test' server = smtplib.SMTP('smtp.gmail.com') server.set_debuglevel(1) server.ehlo() server.starttls() server.ehlo() server.login('[email protected]', 'password')server.sendmail('[email protected]', '[email protected]', msg)server.close() This error message keeps coming up: Traceback (most recent call last): File "C:/Python25/send_mail.py", line 5, in <module> server = smtplib.SMTP('smtp.gmail.com') File "C:\Python25\Lib\smtplib.py", line 244, in __init__ (code, msg) = self.connect(host, port) File "C:\Python25\Lib\smtplib.py", line 310, in connect raise socket.error, msg error: (10061, 'Connection refused')
'Connection refused' usually means that the other side doesn't like you for some reason. (In other words, it doesn't look like a Python problem but like a network problem.)
Since it happens before you can start the protocol, my guess is that smtp.gmail.com does not accept your machine as valid to speak SMTP with (at least not at the port you are trying).
The person to talk to would be the owner/admin of smtp.gmail.com. Sincerely, Albert _______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
