We use mutt to send out emails.
mutt -s "Test" -e "Content-Type: text/html" test@example.com < message.html
We send out our email updates in HTML format. We would like to send emails as multi-part containing both a text version and an html version.
- How do we create such a multipart message in Linux when the email subject, and HTML and text versions of the email body are given?
- Can we use mutt to send the multipart email created in step 1, from the linux prompt?
Envirnonment: RedHat Enterprise Linux 5, mutt
Best Answer
Create a message of type
multipart/alternative
as documented in RFC 2046:See RFC 2046 and RFC 5322 for the exact syntax.
If you find a way to set the right Content-Type header. (In your example, you are using
-e
, but mutt uses-e
for different purposes. Even-e "my_hdr Content-Type: ..."
leaves the original text/plain header intact.)It's better to send generated mail directly through
sendmail
. You'll have to create the headers yourself – see the example; usestrftime("%a, %d %b %Y %T %z")
for Date and a string of random alphanumeric characters for the boundary. Then pipe the prepared message, including headers, tosendmail -i -t
:(The
-t
option means "get recipients from the To: line"; you can alternatively usesendmail -i joe.u@example.net
)