Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'd like to create a text/plain message using Markdown formatting and transform that into a multipart/alternative message where the text/html part has been generated from the Markdown. I've tried using the filter command to filter this through a python program that creates the message, but it seems that the message doesn't get sent through properly. The code is below (this is just test code to see if I can make multipart/alternative messages at all.

import sys
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

html = """<html>
          This is <i>HTML</i>

msgbody = sys.stdin.read()

newmsg = MIMEMultipart("alternative")

plain = MIMEText(msgbody, "plain")
plain["Content-Disposition"] = "inline"

html = MIMEText(html, "html")
html["Content-Disposition"] = "inline"


print newmsg.as_string()

Unfortunately, in mutt, you only get the message body sent to the filter command when you compose (the headers are not included). Once I get this working, I think the markdown part won't be too hard.

share|improve this question
I don't know if it's appropriate here: have you tried to 'set edit_headers' in muttrc? This lets you edit the whole message with your favorite editor including the headers. From that point on it only depends on the capabilities of your editor what you can do with the message. –  sparkie Feb 7 '13 at 16:58
@sparkie I was hoping to automate where I could, but I think you're certainly right that I could make multipart/alternative messages this way. –  Chris W. Feb 7 '13 at 20:43
just a remote idea, but I think mutt can't prevent you from temporarily setting up your "external editor" as a python script –  naxa Jan 16 at 4:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.