Last active
January 27, 2024 16:25
-
-
Save vnegi10/69fd21ec1e42be704bd13b04f964c98c to your computer and use it in GitHub Desktop.
This file contains 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 | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
def send_price_alert(to_email, subject, body): | |
# Replace with your Gmail email address | |
sender_email = 'nftdemoapp@gmail.com' | |
# Replace with your Gmail app password | |
sender_password = get_app_password() | |
# Email content | |
msg = MIMEMultipart() | |
msg['From'] = sender_email | |
msg['To'] = to_email | |
msg['Subject'] = subject | |
# Attach the body of the email | |
msg.attach(MIMEText(body, 'plain')) | |
# Establish a connection to the SMTP server | |
with smtplib.SMTP('smtp.gmail.com', 587) as server: | |
server.starttls() | |
server.login(sender_email, sender_password) | |
# Send the email | |
server.sendmail(sender_email, to_email, msg.as_string()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment