smtp debugging methods

Sean Nakasone seannakasone at
Fri Sep 14 12:21:42 CEST 2007

I'm having trouble with sending smtp mail.  It's hanging after the 
smtplib.SMTP() line. It doesn't works from home but not from work.  What's 
the best way to debug this?

# Here's my script
import smtplib
msg = "Subject: Hello\n\nThis is the\nbody of the message."
server = smtplib.SMTP("",465)
   # "Connection refused" normally means there is no server listening for
   # connections on the specified IP/port-combination.
   # use netstat -an to view connections.
# !!! set the password
server.login("myuser", "mypass")

# Here's the error
>>> server = smtplib.SMTP("",465)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "/usr/lib/python2.4/", line 241, in __init__
     (code, msg) = self.connect(host, port)
   File "/usr/lib/python2.4/", line 304, in connect
     (code, msg) = self.getreply()
   File "/usr/lib/python2.4/", line 345, in getreply
     line = self.file.readline()
   File "/usr/lib/python2.4/", line 340, in readline
     data = self._sock.recv(self._rbufsize)
socket.error: (113, 'Software caused connection abort')

More information about the Python-list mailing list