I am using the Python library smtplib
to send Email messages with Office365 as the SMTP server. Everything was fine until a few days ago when my From:
header seemed to not be processed. The Python code I am using:
import smtplib
from email.mime.text import MIMEText
def login():
server = smtplib.SMTP(mail.mail_server, mail.mail_port)
server.starttls()
server.login(mail.mail_username, mail.mail_password)
return server
def send(subject, body):
msg = MIMEText(body)
msg["From"] = mail.mail_from
msg["To"] = ", ".join(mail.mail_to)
msg["Subject"] = subject
server = login()
server.sendmail(mail.mail_username, mail.mail_to, msg.as_string())
server.quit()
send("test", "test")
What is strange is that if I log onto Outlook or OWA, I can see my header if I view the sent message details. I sent a test header of From: xxxx <info@...>
However on the recipients inbox message, the header is simply the Office365 User's name and the info address as shown above ( From: Name <info@...>
). The xxxx custom header is gone.
What can be causing my header to be dropped?
尽管这可能不是理想的解决方案,但我最终使用自己想要的名称设置了一个新的电子邮件帐户并使用了该帐户,而不是尝试强制使用From:
标头。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.