首页 > 解决方案 > 发件人电子邮件地址缩短(SMTP python 2.7.9)

问题描述

我尝试使用 SMTP (Python 2.7.9) 发送电子邮件。

我提供的发件人是“kmuthukumar@example.com”,但是在收件人的收件箱中,发件人被缩短为“ukumar@example.com”,这是我们系统中的另一个现有用户。

知道是什么原因造成的吗?

更多信息:此问题仅在使用“kmuthukumar”作为发件人的代码生成电子邮件时发生。当 kmuthukumar 通过电子邮件应用程序发送电子邮件时,结果是正常的。原始代码适用于所有其他用户。

import time
from smtplib import SMTP
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

server='internal-smtp.example.com'
sender="kmuthukumar@example.com"
recipients = ['user@example.com']
cc=[]

msg = MIMEMultipart()
msg["From"] = sender
msg["To"]=", ".join(recipients) if isinstance(recipients, list) else recipients
msg["Subject"] = "test"
msg['Date'] = time.ctime(time.time())

subtype='plain'
charset='utf-8'

message = "hello"
text = MIMEText(message, _subtype=subtype, _charset=charset)

msg.attach(text)

smtp = SMTP(server)
smtp.sendmail(sender, list(set(recipients+cc)), msg.as_string())
smtp.quit()

标签: python-2.7smtplib

解决方案


推荐阅读