mutt command with multiple attachments in single m

2019-03-14 18:59发布

问题:

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

回答1:

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 ...


回答2:

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


标签: unix mutt mailx