Guest User

Untitled

a guest
Jul 16th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import smtplib
  4.  
  5. sender = 'aomar.farooq@gmail.com'
  6. receivers = ['aomar.farooq@gmail.com']
  7.  
  8. message = """From: From Person <aomar.farooq@gmail.com>
  9. To: To Person <aomar.farooq@gmail.com>
  10. Subject: SMTP e-mail test
  11.  
  12. This is a test e-mail message.
  13. """
  14.  
  15. try:
  16.    smtpObj = smtplib.SMTP('smtp.gmail.com',465)
  17.    
  18.    smtpObj.ehlo()
  19.    smtpObj.starttls()
  20.    smtpObj.ehlo()
  21.    
  22.    smtpObj.login(sender, '')
  23.    smtpObj.sendmail(sender, receivers, message)
  24.    print "Successfully sent email"
  25.    
  26.    smtpObj.close()
  27. except SMTPException:
  28.    print "Error: unable to send email"
Add Comment
Please, Sign In to add comment