Skip to content

Instantly share code, notes, and snippets.

@redgeoff
Created March 2, 2022 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redgeoff/ce930cfe4529349c8bb8a5b06784dea2 to your computer and use it in GitHub Desktop.
Save redgeoff/ce930cfe4529349c8bb8a5b06784dea2 to your computer and use it in GitHub Desktop.
Grocery Shopping Bot: Email.py
import smtplib, ssl
from email.message import EmailMessage
def send_html_email(smtp_username, smtp_password, smtp_server, smtp_port, email_recipient, subject, body):
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = smtp_username
msg['To'] = email_recipient
msg.add_alternative(body, subtype='html');
context = ssl.create_default_context()
with smtplib.SMTP_SSL(smtp_server, smtp_port, context=context) as server:
server.login(smtp_username, smtp_password)
server.send_message(msg);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment