簡體   English   中英

如何使用sendmail在bash腳本中將文件作為附件發送?

[英]How do I send a file as an attachment in bash script using sendmail?

我正在使用bash腳本。 我想使用sendmail發送電子郵件,使用一個文件作為正文並添加另一個文件作為附件。 我該怎么做呢? 我想通了如何發送第一個文件作為電子郵件正文...

#Send the email
cat - $TFILE1 <<END | /usr/sbin/sendmail -- $to_email
Subject: $subject
To: $to_email

END

但我不知道如何調整以上內容以包含第二個文件(例如,它存儲在$ TFILE2中)作為附件?

我傾向於使用uuencode發送附件,但是使用mailx (我以前從未使用過sendmail )。 要使用uuencode您需要安裝sharutils

uuencodemailx的語法如下:

uuencode attachment.txt attachment.txt | mailx -s "$subject" "$to_email"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM