Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Capture and email a traceback in Python (See related posts)

import traceback, smtplib, StringIO
fp = StringIO.StringIO()
traceback.print_exc(file=fp)
message = fp.getvalue()
server = smtplib.SMTP(FAILURE_SERVER)
server.sendmail(
  FAILURE_FROM,
  FAILURE_TO,
  FAILURE_MESSAGE + '\n\n' + message,
)
server.quit()

Comments on this post

PhoenixR posts on Jun 12, 2006 at 10:44
you need to import StringIO
timmorgan posts on Jun 12, 2006 at 19:35
Fixed.

You need to create an account or log in to post comments to this site.


Click here to browse all 5141 code snippets

Related Posts