DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

Sending Html Mail

09.18.2005
| 7225 views |
  • submit to reddit
        Get the code for createhtmlmail(html, text, subject) <a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/67083>here</a>.
import smtplib
html = open("newsletter.html").read()
text = open("newsletter.txt").read()
subject = "Today's Newsletter!"

message = createhtmlmail(html, text, subject)

server = smtplib.SMTP("localhost")
server.sendmail('my@dress.com', 'your@dress.com', message)
server.quit()