Advertisement
Guest User

Untitled

a guest
Jun 28th, 2016
168
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 = 'postmaster@a.cn'
  4. auth_pass = 'www'
  5. to = ['test@a.cn']
  6.  
  7. msg = """From: <forge@domain.com>
  8. To: <me@gmail.com>
  9. Date: Tue, 28 Jun 2016 01:32:54 +0800
  10. Subject: Test
  11.  
  12. Test mail body.
  13. """
  14.  
  15. s = smtplib.SMTP('127.0.0.1', 587)
  16. s.ehlo('test.com')
  17. s.starttls()
  18. s.ehlo('test.com')
  19.  
  20. try:
  21. s.login(auth_user, auth_pass)
  22.  
  23. # Mail will be sent out.
  24. s.sendmail(auth_user, ','.join(to), msg)
  25.  
  26. # Mail will be rejected due to sender login mismatch.
  27. #s.sendmail('forge@domain.com', ','.join(to), msg)
  28. except Exception, e:
  29. print e
  30. finally:
  31. s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement