📅  最后修改于: 2022-03-11 14:45:37.587000             🧑  作者: Mango
import smtplib
sender = 'company@website.com'
receivers = ['user@example.com']
message = """From: From Person
To: To Person
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"