[Tutor] SMTP('my.smtpserver.com') hangs
Leam Hall
leamhall at gmail.com
Sat Mar 9 18:24:12 CET 2013
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'
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
More information about the Tutor
mailing list