1. 程式人生 > >linux shell 傳送email 附件

linux shell 傳送email 附件

               

方法一:傳送單個附件(正文亂碼)

mutt -s "mail subject" -a output_email.html -- [email protected] < output_email.html

或者

cat output_email.html | mutt -s "mail subject" -a output_email.html -- [email protected]

效果截圖:

郵件正文亂碼

方法二:傳送多個附件(正文不亂碼)

# !/bin/shfrom='[email protected]'to='[email protected]'email_date=''email_subject='subjest'email_content="./folder/file"email_attach="./folder/file ./folder/file2 ./folder/file3 ./folder/file4"function send_email(){    email_date=$(date "+%Y-%m-%d_%H:%M:%S")    email_subject=$email_subject"__"$email_date    cat $email_content | /usr/bin/mutt -s $email_subject -a $email_attach -e 'set content_type="text/html"' -e 'my_hdr from:'$from -- $to}send_email

效果圖:

推薦網站: