我目前正在使用 mailx 从我的脚本发送 html 格式的邮件:
cat body.html | /usr/bin/mailx -a "From: Me <me@domain>" -a "Content-type: text/html" -s "My subject" $RECIPIENTS
现在我想添加一个附件(png 图像),但我不知道如何添加。 我想在转向 mutt 或其他东西之前尝试使用 mailx。 非常感谢
最佳答案
如果您的要求很简单,您可以使用裸Sendmail。这不是我特别推荐的东西,但因为你想避免 mutt
...
# Now that we actually concatenate two files (well, stdin and a file),
# we are no longer eligible for a Useless Use of Cat Award
( cat - body.html <<HERE
Subject: My subject
Mime-Version: 1.0
Content-type: multipart/related; boundary="foooobar"
--foooobar
Content-type: text/html
HERE
cat <<HERE
--foooobar
Content-type: image/png
Content-disposition: inline
Content-transfer-encoding: base64
HERE
base64 image.png
echo; echo '--foooobar--' ) | sendmail -oi $RECIPIENTS
我确实希望有一个简单的标准实用程序来实现这一点,但可惜的是,有很多,或多或少相互不兼容且模糊。再说一遍,如果您可以使用 mutt
,那么这可能是您所期望的最广泛支持和标准的工具。
关于html - 使用 mailx 发送带有 HTML 正文和附件的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22308035/