我正在使用 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
这没有用
我将此 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)。
最佳答案
尝试
echo "<b>HTML Message goes here</b>" | mail -s "$(echo -e "This is the subject\nContent-Type: text/html")" foo@example.com
关于linux 邮件添加内容类型 header 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22457922/