[Tutor] SMTP('my.smtpserver.com') hangs

Joel Goldstick joel.goldstick at gmail.com
Sat Mar 9 19:35:14 CET 2013


On Sat, Mar 9, 2013 at 12:24 PM, Leam Hall <leamhall at gmail.com> wrote:

> Python 2.6.6 on CentOS 6
>
> I'm in section 3.4.12 of Wesley Chun's "Core Python Applications
> Programming". The POP3 stuff works but I can't seem to get the SMTP to
> connect, it just hangs and then times out. Running it in IDLE gets the same
> thing. Have also tried with the port # set, as well.
>
> Thoughts?
>
> Leam
>
> ####
>
> #!/usr/bin/env python
>
> from smtplib import SMTP
> from poplib import POP3
> from time import sleep
>
> SMTPSVR = 'my.smtpserver.com'
> POP3SVR = 'my.smtpserver.com'
>
> who = 'me at smtpserver.com'
>
>
> The line below looks suspect.

> user = 'me+smtpserver.com'
> pass_ = 'my_super_secret'
>
> body = '''\
> From: %(who)s
> To: %(who)s
> Subject: test e-mail
>
> Hello world!
> ''' % {'who' : who }
>
> send_svr = SMTP(SMTPSVR)
> errs = send_svr.sendmail(who, [who], body)
> send_svr.quit()
>
> assert len(errs) == 0, errs
>
> print "Starting sleep"
>
> sleep(10)
>
> recv_svr = POP3(POPSVR)
> recv_svr.user(user)
> recv_svr.pass_(pass_)
> rsp, msg, siz = recv-svr.retr(recv_svr.stat()[**0])
> recv_svr.quit()
> sep = msg.index('')
> recv_body = msg[sep+1:]
> recv_svr.quit()
> assert body == recv_body
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130309/584bbd7c/attachment.html>


More information about the Tutor mailing list