繁体   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