[Tutor] SMTP Module Help
Damon Timm
damontimm at gmail.com
Wed Jan 7 16:48:36 CET 2009
On 1/6/09, Marco Petersen <marco.m.petersen at gmail.com> 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.
I used this example to get emailing from python through gmail smtp to work:
http://codecomments.wordpress.com/2008/01/04/python-gmail-smtp-example/
Note, there are a couple errors in the code that prevent it from
working out-of-the-box ... however, if you read the comments they get
worked out.
Also, I think I would echo what the other folks mentioned here, is
that you probably need to specify the port (587) as in:
server = smtplib.SMTP('smtp.gmail.com', 587)
Damon
>
> 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('marco.m.petersen at gmail.com', 'password')
> server.sendmail('marco.m.petersen at gmail.com',
> 'marcoleepetersen at gmail.com', 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')
>
>
> Can anyone help me with this?
>
> Thanks.
>
> -Marco
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list