# multipart/alternative [RFC1341] defines MIME types, a mechanism for email clients to figure out what to do with a message type. One of these special type is "multipart/alternative", which means that the message body is available under multiple formats, for example text/plain and text/html. Multipart messages look as follows: > Content-Type: multipart/alternative; boundary="Any piece of text, really" > > The blank line above is needed to separate the headers from the body. > In the case of multipart messages, everything between the headers and > first boundary is ignored. This text is still sent, however. > > --Any piece of text, really > Content-Type: text/html; charset="UTF-8" > >
Check the text/plain version of this email instead.
>
> --Any piece of text, really
> Content-Type: text/plain; charset="UTF-8"
>
> Good, good…
> --Any piece of text, really--
>
> Anything after the last boundary (note the trailing "--") is also
> ignored by the client.
The last part of a multipart message is considered the most important,
and is usually displayed by default (unless your client has a preference
order set).
# mutt(1)
As one of the oldest email clients, mutt(1) can _of course_ send
multipart/alternative messages (release 1.13 [changelog]):
set send_multipart_alternative=yes
set send_multipart_alternative_filter=/usr/local/bin/to_html.sh
Setting this in your config file, and sending an email will automatically
convert any email you send as multipart/alternative, add the current
message, and append an alternative message by passing the message body
inside the filter defined.
The expected filter output is
> $CONTENT_TYPE
>
> Converted message body
>
Both empty lines are important. A filter script to convert text/plain
emails to text/html would thus be (assuming markdown input):
#!/bin/sh
echo text/html
echo
markdown
echo
If you don't want all your emails to be sent with an alternative body,
you can put it in a macro:
send-hook . "set send_multipart_alternative=no"
set send_multipart_alternative_filter=/usr/local/bin/to_html.sh
macro compose M ':set send_multipart_alternative=yes