37

我一直在使用 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 而不是纯文本???

4

5 回答 5

59

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

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

这在我的测试中有效。

于 2011-07-24T08:48:16.350 回答
8

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

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

参考这里

Linux问题

于 2012-09-07T03:44:17.543 回答
6

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

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

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

于 2012-02-08T02:35:48.913 回答
5

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

文件 test.html:

<html>

<head></head>

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

于 2015-08-26T12:44:42.733 回答
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。

于 2011-07-24T11:17:12.530 回答