Sample Python code to send HTML email to recipients. This post assume you already have SES authentication enabled on your EC2 instance to send emails.
import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText with open("TestResults.html") as f: file_content = f.read().rstrip("\n") msg = MIMEMultipart('alternative') recipients = 'venkatesh.madala@gmail.com' html_format = MIMEText(file_content, 'html') msg['Subject'] = "Test Email" msg['To'] = recipients msg.attach(html_format) mail=smtplib.SMTP('kgjg') mail.ehlo() mail.sendmail('test@gmail.com',recipients.split(','),msg.as_string()) mail.close()
No comments:
Post a Comment