4

我正在使用邮件命令从我的 linux 系统发送邮件。

我遇到的问题是邮件的内容类型始终为Content-Type: text/plain; charset=us-ascii.

我正在发送 html 内容,它显示为纯文本。

这是我尝试过的

1)
body="From: me@example.org
To: me@gmail.com
Subject: MIME Test
Mime-Version: 1.0
Content-Type: text/html

<html>
<body>
This is a test.
</body>
</html>";

echo $body| mail -s "testing purpose" reciever@gmail.com

这没有用

我把这个 html 放在 $tempfile 中一个名为 test.html 的文件中,并尝试像这样执行

2)
mail -a 'MIME-Version: 1.0' -a 'Content-Type: text/html; charset=iso-8859-1' "server details" "receiver@gmail.com" < $tempfile

但是没有任何效果,请就此向我提出建议(请仅使用邮件而不是 sendmail/mutt)。

4

1 回答 1

7

尝试

echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" foo@example.com

如何使用 linux 命令行发送 HTML 电子邮件

于 2014-03-17T15:13:32.783 回答