Question

My requirement is to attach all the .csv files in a folder and send them in a single mail.

Here is what have tried,

mutt -s "subject" -a *.csv -- abc@gmail.com < subject.txt

The above command is not working (It's not recognizing multiple files) and throwing the error

Error sending message, child exited 67 (User unknown.).
Could not send the message.

Then I tried using multiple -a option as follows,

mutt -s "subject" -a aaa.csv -a bbb.csv -- abc@gmail.com < subject.txt

This works as expected. But this is not feasible for 100 files for example. I should be able use it with file mask (as like *.csv to take all csv files). Is there is any way we can use like *.csv in single command?

Thanks

Was it helpful?

Solution

Mutt doesn't support such syntax, but it doesn't mean it's impossible. You just have to build the mutt command.

mutt -s "subject" $( printf -- '-a %q ' *.csv ) ...

The command in $( ... ) produces something like this:

-a aaa.csv -a bbb.csv -a ...

OTHER TIPS

Here is the example of sending multiple files using a single command -

mutt -s "Subject" -i "Mail_body text" email_id@abc.com -c email_cc_id@abc.com -a attachment1.pdf -a attachment2.pdf 

At the end of the command line use -a for the attachment .

Some linux system have attachment size limit . Mostly it support less size .

I'm getting backslash( \ ) Additionally

Daily_Batch_Status{20131003}.PDF
Daily_System_Monitoring{20131003}.PDF

printf -- '-a %q ' *.PDF
-a Daily_Batch_Status \ {20131003 \ }.PDF -a Daily_System_Monitoring \ {20131003 \ }.PDF
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top