linux 配置邮件发送 :mail 465

第一步:先到QQ邮箱设置smtp服务开启,设置--》账号,选中两个SMTP开启



第二步:在Linux,root用户下,

1.停⽌止服务:

service sendmail stop

chkconfig sendmail off

2.启动postfix服务: 

service postfix start

chkconfig postfix on postfix check

systemctl status postfix


3.调整参数:

vi /etc/postfix/main.cf inet_interfaces = all


4.创建认证:

mkdir -p /~/.certs/

echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt

certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt

certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt certutil -L -d /~/.certs

cd /~/.certs

certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -I qq.crt

5.配置邮件发送者:

vi /etc/mail.rc

set [email protected]

set smtp=smtps://smtp.qq.com:465

set smtp-auth-user=408200244

#

授权码

set smtp-auth-password=cnnjaqnhtohmeahg set smtp-auth=login

set ssl-verify=ignore

set nss-config-dir=/~/.certs

6.测试:

echo hello word | mail -s " title" [email protected]


7.标准:

发邮件不不带附件

[email protected]

echo -e "`date "+%Y-%m-%d %H:%M:%S"` : The current running $JOB_NAME job num is $RUNNINGNUM in 192.168.137.201 ......" | mail \

-r "From: alertAdmin <${EMAIL}>" \

-s "Warn: Skip the new $JOB_NAME spark job." ${EMAIL}


发邮件带附件

echo -e "`date "+%Y-%m-%d %H:%M:%S"` : Please to check the fail sql attachement."

|

mailx \

-r "From: alertAdmin <${EMAIL}>" \

-a error.log \

-s "Critical:KSSH fail sql." ${EMAIL}



你可能感兴趣的:(linux 配置邮件发送 :mail 465)