我想text/plain使用Markdown格式创建一条消息,并将其转换为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()
Run Code Online (Sandbox Code Playgroud)
不幸的是,在mutt中,只有在编写时才会将消息体发送到filter命令(不包括头文件).一旦我开始工作,我认为降价部分不会太难.
| 归档时间: |
|
| 查看次数: |
1945 次 |
| 最近记录: |