0

I am trying to send an email with 2 attachment by running a shell script. Below is the code:

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

Below is the error i am getting:

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]

I also tried same code with just one attachment and it is still giving me the same error.I also want the body to not be in a single line but be in this format :

Hi
Attached is the xml file as requested.
Regards
Team.
  • Mutt can send email with attachment. – Ivan Mar 12 '20 at 09:18
  • 1
    Does this answer your question? [send email with attachment using Unix](https://stackoverflow.com/questions/44143562/send-email-with-attachment-using-unix) – Digvijay S Mar 12 '20 at 10:09

1 Answers1

0

You can try below command:

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