Linux
本次测试 使用云主机 ,配置 liunx发送邮件至qq邮箱中
1、前往QQ邮箱,在设置-账户-下开启SMTP和获取授权码
2、安装mailx
[root@JD .certs]# yum -y install mailx
[root@JD learn_shell]# which mail
/usr/bin/mail
3、停⽌服务:
service sendmail stop
chkconfig sendmail off
[root@JD ~]# service sendmail stop
Redirecting to /bin/systemctl stop sendmail.service
Failed to stop sendmail.service: Unit sendmail.service not loaded.
[root@JD ~]# chkconfig sendmail off
error reading information on service sendmail: No such file or directory
4、启动postfix服务:
service postfix start
chkconfig postfix on
postfix check
systemctl status postfix
[root@JD ~]# service postfix start
Redirecting to /bin/systemctl start postfix.service
[root@JD ~]# chkconfig postfix on
Note: Forwarding request to 'systemctl enable postfix.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/postfix.service to /usr/lib/systemd/system/postfix.service.
[root@JD ~]# postfix check
[root@JD ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2019-08-23 11:07:54 CST; 31s ago
Main PID: 2145 (master)
CGroup: /system.slice/postfix.service
├─2145 /usr/libexec/postfix/master -w
├─2147 pickup -l -t unix -u
└─2148 qmgr -l -t unix -u
Aug 23 11:07:52 JD systemd[1]: Starting Postfix Mail Transport Agent...
Aug 23 11:07:53 JD postfix/postfix-script[2143]: starting the Postfix mail system
Aug 23 11:07:54 JD postfix/master[2145]: daemon started -- version 2.10.1, configuration /etc/postfix
Aug 23 11:07:54 JD systemd[1]: Started Postfix Mail Transport Agent.
5、调整参数:
[root@JD ~]# vi /etc/postfix/main.cf
添加:inet_interfaces = all
6、生成证书
# 创建证书目录
[root@JD ~]# mkdir -p /root/.certs/
[root@JD ~]# cd .certs/
[root@JD .certs]# ll
total 0
#获取证书内容
[root@JD .certs]# echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = GeoTrust RSA CA 2018
verify return:1
depth=0 C = CN, ST = Guangdong, L = Shenzhen, O = Tencent Technology (Shenzhen) Company Limited, OU = R&D, CN = pop.qq.com
verify return:1
DONE
[root@JD .certs]# ll
total 4
-rw-r--r-- 1 root root 2529 Aug 23 15:46 qq.crt
# 添加证书到数据库
[root@JD .certs]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@JD .certs]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
[root@JD .certs]# ll
total 80
-rw------- 1 root root 65536 Aug 23 15:47 cert8.db
-rw------- 1 root root 16384 Aug 23 15:47 key3.db
-rw-r--r-- 1 root root 2529 Aug 23 15:46 qq.crt
-rw------- 1 root root 16384 Aug 23 15:47 secmod.db
# 列出指定目录下的证书
[root@JD .certs]# certutil -L -d /root/.certs
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
GeoTrust SSL CA C,,
# 标记新人证书、防报错
[root@JD .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i qq.crt
Notice: Trust flag u is set automatically if the private key is present.