zoukankan      html  css  js  c++  java
  • 使用465端口发送邮件

    一、问题描述

    最近由于业务需求,定位到服务发送邮件环节故障,服务器拒绝了25端口,改为mailx工具来进行邮件发送服务。

    二、使用465端口加密发送邮件

    1 关闭其它的邮件工具

    [root@test01 ~]# systemctl stop sendmail
    [root@test01 ~]# systemctl stop postfix

    2 安装mailx

    [root@test01 ~]# yum -y install mailx

    3 开启smtp

    在任何邮箱平台中开启smtp,开启后会得到一个授权码,这个授权码就代替了密码(自行去邮箱开启)。我使用的是sina邮箱

    4 请求数字证书

    (这里用的sina邮箱,所以向sina请求证书)

    [root@test01 ~]# mkdir .certs
    
    [root@test01 ~]# echo -n | openssl s_client -connect smtp.sina.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /root/.certs/sina.crt
    
    [root@test01 ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d /root/.certs -i /root/.certs/sina.crt
    
    [root@test01 ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d /root/.certs -i /root/.certs/sina.crt
    
    [root@test01 ~]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d /root/.certs/./ -i /root/.certs/sina.crt
    
    Notice: Trust flag u is set automatically if the private key is present.
    
    [root@test01 ~]# ls /root/.certs/
    
    sina.crt cert8.db key3.db secmod.db
    
    [root@test01 ~]# certutil -L -d /root/.certs
    
    Certificate Nickname Trust Attributes
    
    SSL,S/MIME,JAR/XPI
    
     
    GeoTrust SSL CA P,P,P

    5 配置/etc/mail.rc

    [root@test01 ~]# vim /etc/mail.rc

    set from=xxx@sina.com #之前设置好的邮箱地址
    set smtp="smtps://smtp.sina.com:465" #邮件服务器
    set smtp-auth-user=xxx@sina.com #之前设置好的邮箱地址
    set smtp-auth-password=xxxx #授权码
    set smtp-auth=login #默认login即可
    set ssl-verify=ignore #ssl认证方式
    set nss-config-dir=/root/.certs #证书所在目录

    6 发送邮件测试

    [root@test01 /opt]# mail -s "test" xxx@sina.com

      hello world
      EOT

    邮件发送成功

  • 相关阅读:
    Linux进程关系
    ambari 卸载脚本
    CentOS-7.2安装Ambari-2.6.1
    MYSQL57密码策略修改
    CentOS7 离线安装MySQL
    centos 安装mysql Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)
    mysql 数据备份
    spring-boot-starter-thymeleaf对没有结束符的HTML5标签解析出错
    ssh: scp命令
    python:os.path
  • 原文地址:https://www.cnblogs.com/alisapine/p/15095184.html
Copyright © 2011-2022 走看看