Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- auth_user = 'postmaster@a.cn'
- auth_pass = 'www'
- to = ['test@a.cn']
- msg = """From: <forge@domain.com>
- To: <me@gmail.com>
- Date: Tue, 28 Jun 2016 01:32:54 +0800
- Subject: Test
- Test mail body.
- """
- s = smtplib.SMTP('127.0.0.1', 587)
- s.ehlo('test.com')
- s.starttls()
- s.ehlo('test.com')
- try:
- s.login(auth_user, auth_pass)
- # Mail will be sent out.
- s.sendmail(auth_user, ','.join(to), msg)
- # Mail will be rejected due to sender login mismatch.
- #s.sendmail('forge@domain.com', ','.join(to), msg)
- except Exception, e:
- print e
- finally:
- s.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement