Sending the mail using mutt command

Rajeesh picture Rajeesh · Feb 25, 2014 · Viewed 29.5k times · Source

I have a requirement where I need to send two files A and B . The file A's content should be displayed as in-line or body of the mail and file B as an attachment.

Is multiple attachment using mutt is possible?

The command

 echo "Hello everyone " | mutt -s 'My mail ' [email protected] -a myFile.txt 

is writing Hello everyone as body of the mail and myFile.txt as an attachment(inline).

Both of my files A and B are dynamically generated, so I cannot have an echo statement.

Answer

Aaron Digulla picture Aaron Digulla · Feb 25, 2014

It's actually very simple:

mutt -s 'My mail ' [email protected] -a report1.txt < report2.txt

If you had two scripts to create the reports, you could use pipes (i.e. no files would be created on disk):

script2 | mutt -s 'My mail ' [email protected] -a <(script1)