[Tutor] Sending Email

Steve Willoughby steve at alchemy.com
Wed Oct 3 22:45:03 CEST 2007


On Wed, Oct 03, 2007 at 04:40:08PM -0400, Paul D. Kraus wrote:
> I have a turbogears app that needs to be able to send out email
> notifications to users. Just plain text, no attachments. Can anyone
> suggest some lightweight module?
> 
> Maybe something Akin to Perl's MIME::Lite.

Python comes with an smtplib module which works very well.  You say 
you want plain text, so just do this:

import smtplib

mail = smtplib.SMTP(mailhost_name)
mail.sendmail(from_addr, to_addr, msg)
mail.quit()

You can use MIME modules too if you want attachments and stuff, but
this is pretty simple for plain text.

-- 
Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.


More information about the Tutor mailing list