如何使用bash命令"sendmail"发送html电子邮件?

omg*_*omg 22 linux sendmail

有人有可用的演示吗?

据说Sendmail不可扩展,但它是免费的,所以我决定现在首先使用它:)

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)


Dav*_*ams 5

此页面应该有所帮助 - http://www.zedwood.com/article/103/bash-send-mail-with-an-attachment

它包括一个用于发送带有 MIME 附件(即包含 HTML 页面和图像)的电子邮件的脚本。


Nic*_*son 5

我知道您要求使用 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