import smtplib from email.message import EmailMessage from email.utils import make_msgid msg = EmailMessage() asparagus_cid = make_msgid() msg.add_alternative("""\
Hello
Here is an example of sending HTML email using Python. Please click on below link: Send an HTML email using Python
""".format(asparagus_cid=asparagus_cid[1:-1]), subtype='html') fromEmail = 'gmail@gmail.com' toEmail = 'gmail@gmail.com' msg['Subject'] = 'HTML Message' msg['From'] = fromEmail msg['To'] = toEmail s = smtplib.SMTP_SSL('smtp.gmail.com', 465) s.login(fromEmail, 'gmail password') s.send_message(msg) s.quit()