By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,590 Members | 1,463 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,590 IT Pros & Developers. It's quick & easy.

smtplib STARTTLS problems

P: n/a
I have a working SMTP client that I need to add TLS capability to, I
absolutely need the client to timeout within a specified time, but when I
use the sock.timeout() line it freezes the reading of chars from SSLFakeFile
used during TLS instead of timing out the client connection. I am
working from my own hacked version of smtplib, but can demonstrate the
problem using the standard module (Python 2.3.4). Can anyone suggest a
workaround hack that I can impliment in my own version of smtplib ??

Thanks in advance

Working version =

import smtplib as mx
s=mx.SMTP('e32.co.us.ibm.com')
s.set_debuglevel(1)
s.ehlo('x')
resp, null = s.starttls()
if resp == 220:
s.ehlo('x')
s.mail('m*@mydomain.com')
s.quit()

Non-Working version =

import smtplib as mx
s=mx.SMTP('e32.co.us.ibm.com')
s.sock.settimeout(20)
s.set_debuglevel(1)
s.ehlo('x')
resp, null = s.starttls()
if resp == 220:
s.ehlo('x')
s.mail('m*@mydomain.com')
s.quit()

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "tls2.py", line 8, in ?
print s.ehlo('x')
File "C:\Python23\lib\smtplib.py", line 404, in ehlo
(code,msg)=self.getreply()
File "C:\Python23\lib\smtplib.py", line 356, in getreply
line = self.file.readline()
File "C:\Python23\lib\smtplib.py", line 160, in readline
chr = self.sslobj.read(1)
sslerror: The read operation timed out

Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.