suosuo 2020-02-20
1)配置hosts映射
[ ~]# 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 [ ~]# 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工具
[ ~]# yum -y install postfix mailx [ ~]# systemctl start postfix [ ~]# systemctl enable postfix [ ~]# netstat -anput | grep 25 tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 1820/master
3)定义Postfix配置文件
[ ~]# 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邮件证书
[ ~]# mkdir /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 Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt [ ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt [ ~]# certutil -L -d /root/.certs [ ~]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ~/.certs/ -i ~/.certs/163.crt
5)借用163邮箱发送邮件
[ ~]# vim /etc/mail.rc set ssl-verify="ignore" set smtp-auth="login" set from="" set smtp="smtps://smtp.163.com:465" set smtp-auth-user="" set smtp-auth-password="123456" set nss-config-dir="/root/.certs"
6)重启服务并发送测试邮件
[ ~]# systemctl restart postfix [ ~]# echo "This is a test mail" | mail -s ‘邮件测试‘
7)确认接收邮件
【只是为了打发时间】