Popular recipes by Art Gillespie http://code.activestate.com/recipes/users/122951/2001-08-21T14:36:21-07:00ActiveState Code RecipesSend HTML Mail From Python (Python)
2001-08-21T14:36:21-07:00Art Gillespiehttp://code.activestate.com/recipes/users/122951/http://code.activestate.com/recipes/67083-send-html-mail-from-python/
<p style="color: grey">
Python
recipe 67083
by <a href="/recipes/users/122951/">Art Gillespie</a>
.
</p>
<p>After wrestling and wrestling with Outlook 2000 to turn <em>off</em> HTML mail, I had to figure out how to send HTML from Python for a recent project. Oh the irony, the irony.</p>
<p>It's good policy (and trivially easy) to embed two versions of your message if you're planning on sending HTML mail: the HTML version, and a text-only version. Lots of folks still prefer their character-mode MUAs (viva Mutt!) so don't go alienating them by sending them something that they can't read.</p>
<p>The e-mails generated by this code have been tested on and render correctly with Outlook 2000, Eudora 4.2, Hotmail, and Netscape Mail. It's likely that they will work in other HTML-capable MUAs as well.</p>