Skip to content

Instantly share code, notes, and snippets.

@vnegi10
Last active January 27, 2024 16:25
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 vnegi10/69fd21ec1e42be704bd13b04f964c98c to your computer and use it in GitHub Desktop.
Save vnegi10/69fd21ec1e42be704bd13b04f964c98c to your computer and use it in GitHub Desktop.
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