zoukankan      html  css  js  c++  java
  • Linux Centos7发送QQ邮件

    一、关闭本机的sendmail服务或者postfix服务

    #sendmial
    service sendmail stop
    chkconfig sendmail off
    
    #postfix
    service postfix stop
    chkconfig postfix off
    

    二、安装mailx

    yum -y install mailx
    ln -s /bin/mailx /bin/mail
    chown -R zabbix.zabbix /bin/mail
    

    三、安装证书

    mkdir -p /etc/pki/nssdb/
    cd /etc/pki/nssdb
    
    echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /etc/pki/nssdb/qq.crt 
     
    certutil -A -n "GeoTrust SSL CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt  
    certutil -A -n "GeoTrust Global CA" -t "C,," -d /etc/pki/nssdb/ -i /etc/pki/nssdb/qq.crt  
    certutil -L -d /etc/pki/nssdb/ 
    certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu"  -d ./ -i qq.crt 
    

    四、配置邮件

    (1)获取授权码




    安装步骤操作,发送完邮件会生成一个授权码,复制保存稍后使用

    (2)配置邮件信息

    vim /etc/mail.rc
    

    在文本最后插入

    set nss-config-dir=/etc/pki/nssdb/
    set smtp-user-starttls
    set ssl-verify=ignore
     
    set from=123456@qq.com #使用自己的QQ邮箱,这个是发件箱
    set smtp=smtps://smtp.qq.com:465
    set smtp-auth-user=123456@qq.com #外部smtp服务器认证的用户名,也是QQ邮箱
    set smtp-auth-password=授权码
    set smtp-auth=login
    

    五、测试

    echo  test | mail -v -s " test"  test@qq.com  #此邮箱为收件箱,使用其他邮箱作为收件箱
    

    测试成功

    测试失败(这是多半是证书问题)

    参考资料

    Linux 使用命令发送邮件
    Linux CentOS7 Zabbix邮件报警 通过QQ企业邮箱发送邮件的问题解决方案

  • 相关阅读:
    HDU 1010 Tempter of the Bone
    HDU 4421 Bit Magic(奇葩式解法)
    HDU 2614 Beat 深搜DFS
    HDU 1495 非常可乐 BFS 搜索
    Road to Cinema
    Sea Battle
    Interview with Oleg
    Spotlights
    Substring
    Dominating Patterns
  • 原文地址:https://www.cnblogs.com/Lin1031/p/14401289.html
Copyright © 2011-2022 走看看