[英]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.