我已经编写了一个简单的Python脚本,它使用MIMEMultipart和SMTPLib向收件人数组发送邮件。 代码看起来是这样的:Python邮件在Outlook中放置未占用空间主题行
import smtplib
import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
sender='[email protected]'
recipients='[email protected]'
subject='A pretty long subject line which looks like this'
mail_server='microsfot_exchange_server_ip'
msg = MIMEMultipart('alternative')
body='Body of the Email'
msg['Subject'] = subject
msg['from'] = sender
msg['to'] = ", ".join(recipients)
s = smtplib.SMTP(mail_server)
s.sendmail(sender, recipients, msg.as_string())
s.quit()
这成功地发送了一封邮件,但像在Outlook邮件客户端的主题看起来是这样的:
A pretty long subject line which looks like this
如果您可以包含由Python创建的消息(msg.as_string()'的输出)和客户端接收的电子邮件(Outlook))的相关头文件将很有帮助。 – 2014-09-04 17:34:31
另请参见:您正在使用哪种Python版本? – 2014-09-04 17:48:21
这里是什么样子的标题: '主题:一个相当长的主题行看起来 \t像this' 我使用Python 2.7 – screwgoth 2014-09-04 18:08:29