python-2.7 - 发件人电子邮件地址缩短(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()
解决方案
推荐阅读
- if-statement - Vensim 中的 IF THEN 语句
- charts - 将两点注释之间的百分比变化添加到图表,同时保持值点
- flutter - 如何在颤振中重建父小部件?
- typescript - 使用 Cypress 选择不包含文本的 cypress 元素
- c++ - Qt - 尝试在布局中对齐两个 GroupBox
- azure - 消费者在几个小时后停止阅读消息
- python - 如何在python服务器中连接sql3
- sql - 用空值替换表中的所有 0
- oracle - 如何在 docker 容器内的 Oracle 数据库上使用 sqlldr?
- c++ - 如何在继承类之前初始化成员变量