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