1from email.mime.multipart import MIMEMultipart
2from email.mime.text import MIMEText
3import smtplib
4
5def send_email():
6 sender = FROM_EMAIL
7 receiver = ["email@example.com","anotheremail@example.com"] # emails in list for multiple or just a string for single.
8 msg = MIMEMultipart()
9 msg['From'] = FROM_NAME # The name the email is from e.g. Adam
10 msg['To'] = TO_NAME # The receivers name
11 msg['Subject'] = SUBJECT
12 with open(HTML_TEMPLATE) as f:
13 html = f.read()
14 part = MIMEText(html, 'html')
15 msg.attach(part)
16
17 with smtplib.SMTP("smtp.gmail.com") as connection:
18 connection.starttls()
19 connection.login(CONNECTION USERNAME/EMAIL, CONNECTION PASSWORD)
20 connection.sendmail(sender, receiver, msg.as_string())