📜  python3 发送邮件 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.587000             🧑  作者: Mango

代码示例1
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"