我尝试过以下代码
export HOST=`cat /etc/hostname`
function send {
#$count is defined
if [ $count != "0" ]; then
#send mail
/bin/echo "Hello world"|/usr/bin/mail -s "$HOST - server: Count = $count" -aFrom:noreply\<[email protected]\> [email protected]
fi
}
在我编辑主题以包含 $HOST 后,脚本停止发送电子邮件