【发布时间】:2013-01-17 10:14:08
【问题描述】:
我想使用 Markdown 格式创建 text/plain 消息并将其转换为 multipart/alternative 消息,其中 text/html 部分已从 Markdown 生成。
我尝试使用 filter 命令通过创建消息的 python 程序对其进行过滤,但似乎消息没有正确发送。代码如下(这只是测试代码,看看我是否可以发送multipart/alternative 消息。
import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
html = """<html>
<body>
This is <i>HTML</i>
</body>
</html>
"""
msgbody = sys.stdin.read()
newmsg = MIMEMultipart("alternative")
plain = MIMEText(msgbody, "plain")
plain["Content-Disposition"] = "inline"
html = MIMEText(html, "html")
html["Content-Disposition"] = "inline"
newmsg.attach(plain)
newmsg.attach(html)
print newmsg.as_string()
不幸的是,在 mutt 中,您只能在撰写时获得发送到过滤器命令的消息正文(不包括标题)。一旦我得到这个工作,我认为降价部分不会太难。
【问题讨论】: