Brak opisu

emailTest.py 579B

1234567891011121314151617181920212223242526272829
  1. import smtplib
  2. import sys
  3. gmail_user = 'jose.reyes46@upr.edu'
  4. gmail_password = sys.argv[1]
  5. sent_from = gmail_user
  6. to = "emmanuel.nieves@upr.edu"
  7. subject = 'Usuario y password para ADA'
  8. body = 'Hey, what\'s up?\n\n- You'
  9. email_text = """
  10. From: %s
  11. To: %s
  12. Subject: %s
  13. %s
  14. """ % (sent_from, to, subject, body)
  15. try:
  16. server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
  17. server.ehlo()
  18. server.login(gmail_user, gmail_password)
  19. server.sendmail(sent_from, to, email_text)
  20. server.close()
  21. print 'Email sent!'
  22. except:
  23. print 'Something went wrong...'