Skip to content

Instantly share code, notes, and snippets.

@M507
Created April 6, 2021 20:25
Show Gist options
  • Save M507/e990a777ac1b1afc88b2cad96ff7e6e1 to your computer and use it in GitHub Desktop.
Save M507/e990a777ac1b1afc88b2cad96ff7e6e1 to your computer and use it in GitHub Desktop.
Send_email.py
import smtplib
def send_data():
gmail_user = '[email protected]'
gmail_password = 'password' # env_var
# Create Email
mail_from = gmail_user
mail_to = "[email protected]"
mail_subject = 'You have a massage'
mail_message_body = 'Body \n'
mail_message = 'From: '+ gmail_user +'\nTo: ' + mail_to + '\nSubject: You have a new massage\n'+mail_message_body+'\n\n'
# Sent Email
server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
server.login(gmail_user, gmail_password)
server.sendmail(mail_from, mail_to, mail_message)
server.close()
send_data()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment