Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import smtplib
- sender = 'aomar.farooq@gmail.com'
- receivers = ['aomar.farooq@gmail.com']
- message = """From: From Person <aomar.farooq@gmail.com>
- To: To Person <aomar.farooq@gmail.com>
- Subject: SMTP e-mail test
- This is a test e-mail message.
- """
- try:
- smtpObj = smtplib.SMTP('smtp.gmail.com',465)
- smtpObj.ehlo()
- smtpObj.starttls()
- smtpObj.ehlo()
- smtpObj.login(sender, '')
- smtpObj.sendmail(sender, receivers, message)
- print "Successfully sent email"
- smtpObj.close()
- except SMTPException:
- print "Error: unable to send email"
Add Comment
Please, Sign In to add comment