如何在Unix中发送带有附件的电子邮件

时间:2020-03-12 08:54:31

标签: linux shell unix email-attachments

我正在尝试通过运行Shell脚本来发送带有2个附件的电子邮件。下面是代码:

echo "hi attached is the xml file requested.regards Team."| mailx -a this/is/the/path/tools/v2/xml/bad_out/0106_out.xml,this/is/the/path/tools/v2/xml/bad_out/0107_out.xml muc@tm.com,ti@b.com

以下是我得到的错误:

mail: invalid option -- a
Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [-- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

我也只用一个附件尝试了相同的代码,但它仍然给我相同的错误。我也希望主体不要在一行中,而是在这种格式下:

Hi
Attached is the xml file as requested.
Regards
Team.

1 个答案:

答案 0 :(得分:0)

您可以尝试以下命令:

echo -e "Hi\nAttached is the xml file as requested.\nRegards,\nTeam" | mailx -s "Attachments" -a file1 -a file2 example@domain.com 
相关问题