Guest User

Untitled

a guest
Jun 28th, 2016
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import smtplib
  2.  
  3. auth_user = '[email protected]'
  4. auth_pass = 'www'
  5.  
  6. msg = """From: <[email protected]>
  7. Date: Tue, 28 Jun 2016 01:32:54 +0800
  8. Subject: Test
  9.  
  10. Test mail body.
  11. """
  12.  
  13. s = smtplib.SMTP('127.0.0.1', 587)
  14. s.ehlo('test.com')
  15. s.starttls()
  16. s.ehlo('test.com')
  17.  
  18. try:
  19. s.login(auth_user, auth_pass)
  20.  
  21. # Mail will be sent out.
  22. s.sendmail(auth_user, ','.join(to), msg)
  23.  
  24. # Mail will be rejected due to sender login mismatch.
  25. #s.sendmail('[email protected]', ','.join(to), msg)
  26. except Exception, e:
  27. print e
  28. finally:
  29. s.quit()
Advertisement
Add Comment
Please, Sign In to add comment