Send Html page As Email using “mutt”

匆匆过客 提交于 2019-11-30 04:20:46
vstm

When I try your command, mutt is telling me that content_type=text/html is an unknown command. So you have to use the "set" command to make this work:

mutt -e "set content_type=text/html" Email address -s "subject" < test.html

That worked in my tests.

I tried with mutt 1.6d and that option -e "set content_type=text/html" doesn't work for me. After search around i found below command line works for me:

mutt -e "my_hdr Content-Type: text/html" test@yahoo.com  -s "subject" < mytest.html

Reference here

LinuxQuestions

my mutt version is 1.4.x, and I also cannot set content_type=text/html, it is reported as unknown variable.

and I checked the mutt doc, the content_type is only supported by version 1.5.x, such as the latest version 1.5.21.

obviously, html mail was not supported by version 1.4.x.

I use Mutt 1.5.23 to send an html email with embedded image, and this works for me. mutt -e "set content_type=text/html" Email -s "subject" -a pic.png < test.html

file test.html:

<html>

<head></head>

<body>
  <img src="cid:pic.png" " />
</body>
</html>

If you look at the source of an HTML email, you'll see at minimum something like:

Subject: test html mail
From: sender@example.com
To: recipient@example.com
Content-Type: multipart/alternative; boundary=bcaec520ea5d6918e204a8cea3b4

--bcaec520ea5d6918e204a8cea3b4
Content-Type: text/plain; charset=ISO-8859-1

*hi!*

--bcaec520ea5d6918e204a8cea3b4
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<p><b>hi!</b></p>

--bcaec520ea5d6918e204a8cea3b4--

So, you have to create a "Content-Type:" header, and add the boundaries above the text-only version, and above and below the HTML version.

Given the amount of hand-crafting required, you might as well hand the message over to sendmail instead of mutt.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!