使用“mutt”将Html页面发送为电子邮件

时间:2011-07-24 08:36:54

标签: bash mutt

我一直在使用mutt从另一个应用程序内部发送电子邮件。 它工作正常。我必须发送html文件,目前我必须发送 他们作为附件。所以我用

mutt -s "hi" -a attach.html user@domain.com < /dev/null

但是如果我尝试将html文件作为正文发送如下

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

然后我得到html文件的源文本而不是html文件。

有什么方法可以将消息正文作为html 而不是纯文本???

5 个答案:

答案 0 :(得分:47)

当我尝试你的命令时,mutt告诉我content_type=text/html是一个未知的命令。所以你必须使用“set”命令来完成这项工作:

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

这在我的测试中有效。

答案 1 :(得分:7)

我尝试使用mutt 1.6d并且选项-e“set content_type = text / html”对我不起作用。搜索后我发现下面的命令行为我工作:

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

参考这里

LinuxQuestions

答案 2 :(得分:5)

我的mutt版本是1.4.x,我也无法设置content_type = text / html,它被报告为未知变量。

我检查了mutt doc content_type 仅受1.5.x版支持,例如最新版本1.5.21。

显然,版本1.4.x不支持html邮件。

答案 3 :(得分:2)

我使用Mutt 1.5.23发送带有嵌入式图像的html电子邮件,这对我有用。 mutt -e "set content_type=text/html" Email -s "subject" -a pic.png < test.html

file test.html:

&#13;
&#13;
<html>

<head></head>

<body>
  <img src="cid:pic.png" " />
</body>
</html>
&#13;
&#13;
&#13;

答案 4 :(得分:0)

如果您查看HTML电子邮件的来源,您至少会看到以下内容:

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--

因此,您必须创建“Content-Type:”标题,并在纯文本版本上方以及HTML版本的上方和下方添加边界。

考虑到手工制作所需的数量,您不妨将消息传递给sendmail而不是mutt。