码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS使用Postfix发送邮件

时间:2020-02-20 17:09:37      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:code   mic   ==   ns3   host   put   mail -s   systemctl   邮箱   

1)配置hosts映射

[root@mail ~]# ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.2.3.11  netmask 255.255.255.0  broadcast 10.2.3.255
        inet6 fe80::20c:29ff:fec1:6505  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c1:65:05  txqueuelen 1000  (Ethernet)
        RX packets 8665  bytes 10401537 (9.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1752  bytes 217252 (212.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@mail ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.2.3.11	mds.com
10.2.3.11	mail.mds.com

2)安装Postfix与Mailx工具

[root@mail ~]# yum -y install postfix mailx
[root@mail ~]# systemctl start postfix
[root@mail ~]# systemctl enable postfix
[root@mail ~]# netstat -anput | grep 25
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1820/master  

3)定义Postfix配置文件

[root@mail ~]# vim /etc/postfix/main.cf
myhostname = mail.mds.com
mydomain = mds.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname,$mydomain

以下是以上选项的解释:
===================
myhostname	       #邮件系统的主机名
mydomain 	       #邮件系统的域名
myorigin 		       #从本机发出邮件时所用的名称
inet_interfaces	       #监听的网卡接口
mydestination	       #可接收邮件的主机名或域名

4)申请163邮件证书

[root@mail ~]# mkdir /root/.certs
[root@mail ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne ‘/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p‘ > ~/.certs/163.crt
[root@mail ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
[root@mail ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt
[root@mail ~]# certutil -L -d /root/.certs
[root@mail ~]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/ -i ~/.certs/163.crt

5)借用163邮箱发送邮件

[root@mail ~]# vim /etc/mail.rc
set ssl-verify="ignore"
set smtp-auth="login"
set from="mds302587@163.com"
set smtp="smtps://smtp.163.com:465"
set smtp-auth-user="mds302587@163.com"
set smtp-auth-password="123456"
set nss-config-dir="/root/.certs"

6)重启服务并发送测试邮件

[root@mail ~]# systemctl restart postfix
[root@mail ~]# echo "This is a test mail" | mail -s ‘邮件测试‘ 452666750@qq.com

7)确认接收邮件

技术图片

【只是为了打发时间】

CentOS使用Postfix发送邮件

标签:code   mic   ==   ns3   host   put   mail -s   systemctl   邮箱   

原文地址:https://www.cnblogs.com/Linux-mds/p/12336255.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!