1、設定hosts映射
#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
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教學
以上是centos7怎麼使用postfix發送郵件的詳細內容。更多資訊請關注PHP中文網其他相關文章!