import smtplib
sender = 'company@website.com'
receivers = ['user@example.com']
message = """From: From Person <company@website.com>
To: To Person <user@example.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except SMTPException:
print "Error: unable to send email"