Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- gmail_user = 'XXXX@gmail.com'
- gmail_password = 'XXXXXXX'
- from_add = gmail_user
- to = ["AAAAAAAA@gmail.com"]
- subject = 'testing'
- body = 'Hello World! \nThis is a test'
- email_text = """\
- From: %s
- To: %s
- Subject: %s
- %s
- """%(from_add, ", ".join(to), subject, body)
- try:
- smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
- smtpObj.ehlo()
- smtpObj.starttls()
- smtpObj.login(gmail_user, gmail_password)
- smtpObj.sendmail(from_add, to, email_text)
- smtpObj.close()
- print 'Email sent'
- except:
- print 'Something went wrong'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement