繁体   English   中英

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

[英]How to send email with attachment in Unix

我正在尝试通过运行 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.

您可以尝试以下命令:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM