我是shell脚本中的新手,我尝试使用shell脚本发送邮件,如下所示
from="test@mail.com"
to="recive@mail.com"
subject="Title here"
body="This is the body of our email"
declare -a attachments
attachments=( 'test.doc')
declare -a attargs
for att in "${attachments[@]}"; do
attargs+=( "-a" "$att" )
done
/usr/sbin/sendmail -s "$subject" -r "$from" "${attargs[@]}" "$to" <<< "$body"尝试在控制台中运行显示这种类型的错误。
sendmail: invalid option -- 's'
sendmail: invalid option -- 's'
sendmail: fatal: usage: sendmail [options]邮件日志显示以下类型的错误:后缀/ sendmail 4825:致命:使用:sendmail选项
发布于 2015-04-15 06:51:59
sendmail在错误消息中给出了答案:invalid option -- 's',实际上是这样的。-s没有sendmail的选项,因为sendmail通常不被认为是命令行邮件程序。
您将更好地使用mailx或heirloom-mailx等。(这是同一个项目,在过去的几年里,它只是洗牌)。它可能已经安装在您的系统上。与type mailx核对
有关使用/选项,请参见:mailx(1) - Linux man page
https://stackoverflow.com/questions/29642924
复制相似问题