我试图:
我遇到的麻烦大吃一惊,因为我不希望创建多个电子邮件我只是一个创建一个电子邮件与所有包含附件,并在主题行中使用的当前日期和时间。
#!/bin/bash
# to run type "bash email_live_listing.sh"
dt_now_start=`date +"%Y-%m-%d %T"`
fn_dt_now_start=`date '+%Y_%m_%d__%H_%M_%S'`; #use to generate file name with date
currentdir="$(pwd)" #get current directory
ls $currentdir/us*.pdf -tp | grep -v '/$fn_pdf' #place files into variable
echo "$fn_pdf"
ITER=0
for t in ${fn_pdf[@]}; do
swaks --to [email protected] -s smtp.gmail.com:587 -tls -au [email protected] -ap password --header "Subject: Updated file ${fn_dt_now_start}" --body "Email Text" --attach-type ./${fn_pdf} -S 2
let ITER+=1 #increment number
done
附言:我正在使用Ubuntu和Swaks,因为它既紧凑又轻巧,并且可以从树莓派运行,但是我愿意尝试其他选择。
这是一个bash脚本,可能会帮助我工作的其他人。
#!/bin/bash
currentdir="$(pwd)" #get current directory
fn_dt_now_start=`date '+%Y_%m_%d__%H_%M_%S'`; #use to generate date time
fn_txt=$(ls $currentdir/*.txt) #place txt files found into a variable
for t in ${fn_txt[@]}; do
attach_files="${attach_files} --attach-type ${t}" #will build list of files to attach
done
swaks --to [email protected] -s smtp.gmail.com:587 -tls -au [email protected] -ap <email_sending_from_password>] --header "Subject: Listings - ${fn_dt_now_start}" --body "Listings Email Text" ${attach_files} -S 2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句