python3 send mail

Solutions on MaxInterview for python3 send mail by the best coders in the world

showing results for - "python3 send mail"
Athena
15 Jan 2017
1
2import smtplib
3
4sender = 'company@website.com'
5receivers = ['user@example.com']
6
7message = """From: From Person <company@website.com>
8To: To Person <user@example.com>
9Subject: SMTP e-mail test
10
11This is a test e-mail message.
12"""
13
14try:
15   smtpObj = smtplib.SMTP('localhost')
16   smtpObj.sendmail(sender, receivers, message)         
17   print "Successfully sent email"
18except SMTPException:
19   print "Error: unable to send email"
20