linux邮件添加内容类型标头不起作用

ɹɐq*_*ɹǝɟ 4 linux bash shell mailx

我正在使用mail命令从我的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
Run Code Online (Sandbox Code Playgroud)

这没用

我把这个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
Run Code Online (Sandbox Code Playgroud)

但没有任何效果,请建议我这个(请只使用邮件而不是sendmail/mutt).

dei*_*mus 7

尝试

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

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