Ste*_*n L 42
我无法获得任何已发布的解决方案,但最终在其他地方找到了它,并且效果很好:
(
echo "From: ${from}";
echo "To: ${to}";
echo "Subject: ${subject}";
echo "Content-Type: text/html";
echo "MIME-Version: 1.0";
echo "";
echo "${message}";
) | sendmail -t
Run Code Online (Sandbox Code Playgroud)
Spa*_*ace 17
如果我理解正确,您希望使用linux sendmail命令以HTML格式发送邮件.这段代码适用于Unix.请试一试.
echo "From: me@xyz.com
To: them@xyz.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary='PAA08673.1018277622/server.xyz.com'
Subject: Test HTML e-mail.
This is a MIME-encapsulated message
--PAA08673.1018277622/server.xyz.com
Content-Type: text/html
<html>
<head>
<title>HTML E-mail</title>
</head>
<body>
<a href='http://www.google.com'>Click Here</a>
</body>
</html>
--PAA08673.1018277622/server.xyz.com
" | sendmail -t
Run Code Online (Sandbox Code Playgroud)
有关sendmail配置的详细信息,请参阅此链接.希望这可以帮助.
小智 6
- 一个选项?
比照。手册页:
-a file
Attach the given file to the message.
Run Code Online (Sandbox Code Playgroud)
结果:
Content-Type: text/html: No such file or directory
Run Code Online (Sandbox Code Playgroud)
此页面应该有所帮助 - http://www.zedwood.com/article/103/bash-send-mail-with-an-attachment
它包括一个用于发送带有 MIME 附件(即包含 HTML 页面和图像)的电子邮件的脚本。
我知道您要求使用 sendmail 但为什么不使用默认邮件?它可以轻松发送 html 电子邮件。
适用于:RHEL 5.10/6.x 和 CentOS 5.8
例子:
cat ~/campaigns/release-status.html | mail -s "$(echo -e "Release Status [Green]\nContent-Type: text/html")" to.address@company.com -v
Run Code Online (Sandbox Code Playgroud)
代码共享:http : //www.codeshare.io/8udx5
| 归档时间: |
|
| 查看次数: |
107315 次 |
| 最近记录: |