linux下发送邮件脚本

首先安装发送邮件需要的包

yum -y install mailx

#!/bin/bash
source /etc/profile
function send_mail(){
    maillist=(
        [email protected]
    )
    DATE=`date +'%F %T'`
    SUBJECT="主题"
    CONTENT="内容"
        for mail in ${maillist[*]};do
            echo -e "${CONTENT}" | mail -s "${SUBJECT}" $mail
        done
}
send_mail

猜你喜欢

转载自blog.csdn.net/qq_30920479/article/details/105674063