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

标签 linux bash shell mailx

我正在使用 ma​​il 命令从我的 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

How to send HTML email using linux command line

关于linux 邮件添加内容类型 header 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22457922/

相关文章:

bash - OPTIND 变量如何在 shell 内置 getopts 中工作

linux - 使用 grep 和 sed 查找和替换字符串

linux下无法读取文件

python - 删除 Flask Web 应用程序的终端依赖性

python - 为什么 python 套接字不能解析带有 http 的 url

linux - bash 比较变量与字符串

android - 无法在 Android JellyBean 上构建 hello world 内核模块

java - Jenkins - 在不同的机器上使用本地环境变量执行脚本

bash - 使用 Bash 进行函数式编程

Perl 禁用 shell 访问