Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def send_email(to_email, subject, body): #to send an email
- gmail_user = "demosal023@gmail.com"
- gmail_password = "SAL123xyz!"
- sent_from = gmail_user
- to = to_email
- sub = subject
- email_text = """\
- From: %s
- To: %s
- Subject: %s
- %s
- """ % (sent_from,"SAL", sub, body)
- try:
- server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
- server.ehlo()
- server.login(gmail_user, gmail_password)
- server.sendmail(sent_from, to, email_text)
- server.close()
- print ("Email sent!")
- except:
- print ("Something went wrong...")
Add Comment
Please, Sign In to add comment