thread safe SMTP module

Gordon Messmer gmessmer at u.washington.edu
Fri Mar 2 17:58:37 EST 2007


I believe that I've seen this discussed previously, so maybe there's 
some interest in it.  I wrote a threaded mail filtering framework a 
while ago, and one of the modules does address verification via SMTP.  
Since smtplib.SMTP uses blocking IO, it can block the whole 
interpreter.  Sometimes the whole thing would stop working indefinitely.

I'm now aware that Twisted offers a non-blocking SMTP class, but I 
didn't really want to make that a dependency of the address 
verification.  I ended up subclassing the smtplib.SMTP class and 
rewriting the functions that do I/O.  Perhaps someone who doesn't want 
to install Twisted will find this class useful, someday.  It doesn't 
support TLS, but it is otherwise a thread-safe SMTP class.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ThreadSMTP.py
Type: text/x-python
Size: 6331 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20070302/938996e1/attachment.py>


More information about the Python-list mailing list