所以我知道如何使用mail命令通过ssh发送邮件,例如在mail -s "Subject here" [email protected]中inputmail -s "Subject here" [email protected] ,然后input邮件,点击CTRL + D停止撰写,然后按回车键有一个Cc。
我很好奇,如何通过非交互式shell脚本发送电子邮件? 只要这样我可以发送电子邮件,如果备份决定失败,或任何原因。
谢谢一堆!
那么,只是在内容pipe道。 例如
echo "message text"|mail -s "subject" [email protected]
我这样做:
/usr/lib/sendmail -t <<EOF To: [email protected] Subject: My script works Looks like my script is working. EOF
你可以在消息中使用shellvariables。 您也可以根据需要添加CC和BCC行。