Linux下使用mail發送郵件
yum install mailx
vi /etc/mail.rc
set from=[email protected]
set smtp=smtphz.qiye.163.com
set smtp-auth-user=[email protected]
set smtp-auth-password=p@ssword
set smtp-auth=login
mail -s "Title" [email protected]
mail -s "Tile" [email protected] < /root/sms.txt
cat /root/sms.txt | mail -s "Tile" [email protected]
echo "Content" | mail -s "Tile" [email protected]
mail -s "Tile" [email protected] -a /root/sms.txt
檢測磁盤空間
vi check.sh
mail=[email protected]
code=`df | grep -c -E \([6-9][0-9]\%\)\|\(100\%\)`
if [ $code -gt 0 ]
then
df -h | mail -v -s "磁盤空間警告"$(date +%Y%m%d)-$code $mail
fi
chmod 700 check.sh
crontab -e
0 6 * * * ~/check.sh