smtp debugging methods

S

Sean Nakasone

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("smtp.gmail.com",465)
# "Connection refused" normally means there is no server listening for
# connections on the specified IP/port-combination.
# use netstat -an to view connections.
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.ehlo()
# !!! set the password
server.login("myuser", "mypass")
server.sendmail("...

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

Jon Ribbens

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 the error

smtp.gmail.com port 465 is SSL only. Try port 587 instead.
 
T

Tim Williams

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("smtp.gmail.com",465)
# "Connection refused" normally means there is no server listening for
# connections on the specified IP/port-combination.
# use netstat -an to view connections.
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.ehlo()
# !!! set the password
server.login("myuser", "mypass")
server.sendmail("...

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

There is no SMTP service on port 465 , its some other "service" or the
smtp server is in trouble, try it with port 587 instead.

HTH :)
 
T

Tim Roberts

Sean Nakasone said:
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?

It's quite possible that your network at work has a firewall blocking these
ports. Many employers allow outgoing connections only on ports 25, 80, and
443.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top