smtplib, capturing output from set_debuglevel ??

Steve Holden steve at holdenweb.com
Thu Oct 7 18:22:42 CEST 2004


Tim Williams wrote:

> Can anyone suggest a way of capturing the output from smtplib's
> set_debuglevel  into a list or dictionary  (or anything else I can work
> with),   Preferably not to a file,  though if this is the only way,  then it
> would be a start
> 
> I have googled.
> 

All smtplib debug output is produced using print statements to standard 
ouput, so you could try creating a "file-like" object (such as a 
cStringIO) and temporarily replacing sys.stdout with it (saving 
sys.sdout and replacing it if other parts of your program need to use it).

If you need help to work out the details, post again.

regards
  Steeve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119




More information about the Python-list mailing list