centos7发送邮件配置

安装邮件发送软件mailx

    yum -y install mailx

    测试是否安装成功  which mailx


which mailx

编辑配置文件

     vi /etc/mail.rc 在文件末尾添加如下配置

        set from=*****@qq.com #发送邮箱,你的邮箱账号

        set smtp=smtp.qq.com     

        set smtp-auth-user=*******@qq.com    #授权账号,你的邮箱账号

        set smtp-auth-password=*********    #授权码,详见下图

        set smtp-auth=login

        set smtp-use-starttls

        set ssl-verify=ignore

        set nss-config-dir=/root/.certs      #ssl授权文件路径


/etc/mail.rc 

    qq邮箱smtp开启和授权码获取

       登陆网页版qq邮箱

                设置-账户-POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务-开启smtp服务

配置QQ 邮箱ssl证书

        mkdir -p /root/.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 /root/.certs

        cd /root/.certs/

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