Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- gmail_user = 'dummy@gmail.com'
- gmail_password = 'password'
- sent_from = 'dummy@gmail.com'
- to = ['receiver@gmail.com']
- subject = 'OMG Super Important Message'
- body = "Hey, what's up?nn- 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)
- print("establish connection successful")
- server.ehlo()
- print("identification successful")
- server.login(gmail_user, gmail_password)
- print("login successful")
- server.sendmail(sent_from, to, email_text)
- print("send mail successful")
- server.close()
- print('Email sent!')
- except:
- print('Something went wrong...')
Add Comment
Please, Sign In to add comment