I have been using this python function for a while to send html emails from within my python scripts -
def sendhtmlemail(emailbody, subject):
""" Send html email with given subject and body """
fromaddr = readconfig(EMAIL_FROM)
toaddr = readconfig(EMAIL_TO)
msg = MIMEMultipart('alternative')
msg['From'] = fromaddr
msg['To'] = toaddr
msg['Subject'] = subject
body …