当我的程序发送电子邮件时,我无法显示我的电子邮件的主题部分。我以为我在遵循 SMTP 的 RFC 规范。但我似乎无法弄清楚我做错了什么。任何帮助是极大的赞赏。
def email():
sender = 'username@domain.com'
receivers = ['username@domain.com']
message = """From: From Admin <admin@domain.com>
To:To Person <user@domain.com>
Subject: Important Information
This is a test email message.
"""
try:
smtpObj = smtplib.SMTP('domain.com', 25)
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except smtplib.SMTPException:
print('Error: unable to send email')