zoukankan      html  css  js  c++  java
  • Centos7下使用mail发送邮件

    首先检测相关服务是否已安装
    [root@ProxyServer ~]# rpm -qa|grep mail

    libreport-plugin-mailx-2.0.9-19.el6.x86_64

    mailx-12.4-7.el6.x86_64

    procmail-3.22-25.1.el6.x86_64

    mailcap-2.1.31-2.el6.noarch

    sendmail-8.14.4-8.el6.x86_64

    若服务未安,则执行以下命令进行服务安装
    [root@ProxyServer ~]# yum install sendmail

    [root@ProxyServer ~]# yum install mailx –y

    [root@ProxyServer ~]# yum update libreport-plugin-mailx

    [root@ProxyServer ~]# yum -y install sharutils

    [root@ProxyServer ~]# yum install mutt

    修改配置文件,配置邮件相关内容(追加到配置文件末尾)
    [root@ProxyServer ~]# vi /etc/mail.rc

    set from=lvyf0802@163.com #之前设置好的邮箱地址

    set smtp=smtp.163.com #邮件服务器

    set smtp-auth-user=lvyf0802@163.com #之前设置好的邮箱地址

    set smtp-auth-password=lvyf0802 #授权码

    set smtp-auth=login  #默认login

    邮箱开启smtp服务(这里以163邮箱为例)

     


    检测服务是否安装成功
    [root@ProxyServer ~]# touch /usr/mail.txt

    [root@ProxyServer ~]# mail -s "theme" test@163.com < /usr/mail.txt

    //使用上面的命令就可把mail.txt文件的内容发给 test@163.com(-s “theme” 为邮件的主题)

    为了防止垃圾邮件泛滥,阿里云服务器已不再开放smtp邮件的25端口,现在需要使用465端口进行smtp邮件发送。
    生成密钥
    [root@ProxyServer ~]mkdir -p /root/.certs/

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

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

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

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

    certutil -L -d /root/.certs

        2.配置密钥(红色代表修改内容)

    [root@ProxyServer ~]# vi /etc/mail.rc

    set bsdcompat

    set from=lvyf0802@163.com #之前设置好的邮箱地址

    set smtp=smtps://smtp.163.com #邮件服务器

    set smtp-auth-user=lvyf0802@163.com #之前设置好的邮箱地址

    set smtp-auth-password=lvyf0802 #授权码

    set smtp-auth=login  #默认login

    set ssl-verify=ignore #ssl认证方式

    set nss-config-dir=/root/.certs #证书所在目录
    ---------------------
    作者:万一起飞了呢
    来源:CSDN
    原文:https://blog.csdn.net/lyf844692713/article/details/81479066
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    数据集市
    大数据下的企业数据仓库建设
    大数据项目--准备
    ETL利器Kettle实战应用解析系列三 【ETL后台进程执行配置方式】
    ETL利器Kettle实战应用解析系列二 【应用场景和实战DEMO下载】
    ETL利器Kettle实战应用解析系列一【Kettle使用介绍】
    [Leetcode Weekly Contest]202
    [Leetcode Weekly Contest]200
    [Leetcode Weekly Contest]196
    [Leetcode Weekly Contest]195
  • 原文地址:https://www.cnblogs.com/xy51/p/10905652.html
Copyright © 2011-2022 走看看