我想在shell脚本中发送带有html正文和附件的邮件

时间:2018-03-28 12:56:15

标签: bash email unix sendmail

在执行此脚本时,我有一个行附件,我有一个空白的zip文件,但我现有的zip文件确定它没有任何问题。请有人帮我解决这个问题我从网上尝试了很多但是没有用。

export BODY=test.html
(
echo "To:"xyz@abc.com;
echo "Subject:QC Count failed report Please find Attachment.";
echo "MIME-Version: 1.0";
echo "Content-Type:multipart/mixed; boundary=\"B835649000072104Jul07\"";

echo "--B835649000072104Jul07";
echo "Content-Type: text/html; charset=\"UTF-8\"";
echo "Content-Transfer-Encoding: 7bit";
echo "Content-Disposition: inline";
echo "";
echo "";
cat $BODY
echo "--B835649000072104Jul07";
echo "Content-Disposition: attachment; filename=\"$FAILED_ZIP\"";
echo "--B835649000072104Jul07";

) | sendmail -t

1 个答案:

答案 0 :(得分:0)

如何使用swaks命令并附上你的拉链?

swaks -t "abc@xyz.com" -f "noreply@example.com" --header "Subject: QC Count failed report Please find attached" --body " Here are results" --attach /path/to/the/zip/file