Created
March 2, 2022 23:36
-
-
Save redgeoff/ce930cfe4529349c8bb8a5b06784dea2 to your computer and use it in GitHub Desktop.
Grocery Shopping Bot: Email.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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