告诉Mutt的附加文件(文件中列出) [英] Tell Mutt to attach files (listed in file)
问题描述
我在做我的第一个步骤,笨蛋(与msmtp会在Slackware的13.1)。
I'm doing my first steps with Mutt (with msmtp in Slackware 13.1).
我已经能够带附件发送邮件,像这样:
I'm already able to send mail with attachments like so:
cat mail.txt | mutt -a "/date.log" -a "/report.sh" -s "subject of message" -- myself@gmail.com
我想定义在另一个文件中附加的文件,然后告诉马特读它,是这样的:
I would like to define the files to be attached in another file and then tell Mutt to read it, something like this:
mutt -? listoffilestoattach.txt
这可能吗?或者有类似的做法?
Is it possible? Or there are similar approaches?
推荐答案
您可以很容易填充文件名列表的数组,然后使用它作为参数传递给 -a
。
You can populate an array with the list of file names fairly easily, then use that as the argument to -a
.
while IFS= read -r attachment; do
attachments+=( "$attachment" )
done < listoffilestoattach.txt
for f in ../*.log; do
attachments+=("$f")
done
mutt -s "subject of message" -a "${attachments[@]}" -- myself@gmail.com < mail.txt
如果您使用的是庆典
4或更高版本,您可以用(略)替换,而
循环更互动型 readarray
命令:
If you are using bash
4 or later, you can replace the while
loop with the (slightly) more interactive-friendly readarray
command:
readarray -t attachments < listoffilestoattach.txt
如果,因为似乎是如此,狗
要求每个 -a
选项一个单一的文件,那么你会需要的东西稍有不同:
If, as appears to be the case, mutt
requires a single file per -a
option, then you'll need something slightly different:
while IFS= read -r attachment; do
attachments+=( -a "$attachment" )
done < listoffilestoattach.txt
for f in ../*.log; do
attachments+=( -a "$f")
done
mutt -s "subject of message" "${attachments[@]}" -- myself@gmail.com < mail.txt
使用 readarray
,试试
readarray -t attachments < listoffilestoattach.txt
attachments+=( ../*.log )
for a in "${attachements[@]}"; do
attach_args+=(-a "$a")
done
mutt -s "subject of message" "${attach_args[@]}" -- myself@gmail.com < mail.txt
这篇关于告诉Mutt的附加文件(文件中列出)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!