mutt command with multiple attachments in single mail unix

若如初见. 提交于 2019-12-03 08:37:58

问题


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


来源:https://stackoverflow.com/questions/17342450/mutt-command-with-multiple-attachments-in-single-mail-unix

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!