Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- gmail_user = 'YOUR GOOGLE EMAIL'
- gmail_password = 'YOUR PASSWORD'
- sent_from = gmail_user
- to = ['recipient1@gmail.com', 'recipient1@gmail.com']
- subject = 'This is very important email!'
- body = "Hey, what's up?\n\n- You"
- email_text = """
- From: %s
- To: %s
- Subject: %s
- %s
- """ % (sent_from, ", ".join(to), subject, 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...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement