This is a Python script that I used to generate a HTML e-mail. Script is configured to use gmail as the senders mail host with SSL support. Change the mail server if you want to use some other mail server. If you enable the 2-way authentication on google account, that will be another problem.
Note : There are some problems with attachments. Some mail clients (yahoo) don't show the attachment.