123.207.15.141
A 记录
记录类型:A
主机记录:@
记录值:123.207.15.141
MX 记录
记录类型:MX
主机记录:@
记录值:yourdomain.com(替换为自己域名)
yum -y install postfix dovecot
postconf -e 'myhostname = server.yourdomain.com'
postconf -e 'mydestination = localhost, localhost.localdomain'
postconf -e 'myorigin = $mydomain'
postconf -e 'mynetworks = 127.0.0.0/8'
postconf -e 'inet_interfaces = all'
postconf -e 'inet_protocols = all'
postconf -e 'mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain'
postconf -e 'home_mailbox = Maildir/'
postconf -e 'smtpd_sasl_type = dovecot'
postconf -e 'smtpd_sasl_path = private/auth'
postconf -e 'smtpd_sasl_auth_enable = yes'
postconf -e 'broken_sasl_auth_clients = yes'
postconf -e 'smtpd_sasl_authenticated_header = yes'
postconf -e 'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unauth_destination'
postconf -e 'smtpd_use_tls = yes'
postconf -e 'smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem'
postconf -e 'smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem'
打开 /etc/postfix/master.cf 文件,将如下两行前的 # 去除:
smtps inet n - n - - smtpd
-o smtpd_tls_wrappermode=yes
26 smtps inet n - n - - smtpd
27 # -o syslog_name=postfix/smtps
28 -o smtpd_tls_wrappermode=yes
systemctl enable postfix.service
systemctl start postfix.service
cat /var/log/maillog
打开 /etc/dovecot/dovecot.conf 文件,在最下方加入以下配置:
ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
ssl_key = </etc/pki/dovecot/private/dovecot.pem
protocols = imap pop3 lmtp
listen = *
mail_location = Maildir:~/Maildir
disable_plaintext_auth = no
打开 /etc/dovecot/conf.d/10-master.conf 文件,找到 service auth 部分,将以下行前面的 # 去除:
unix_listener /var/spool/postfix/private/auth {
mode = 0666
}
96 unix_listener /var/spool/postfix/private/auth {
97 mode = 0666
98 }
systemctl enable dovecot.service
systemctl start dovecot.service
cat /var/log/maillog
useradd test
passwd test
123456
su test
echo "Mail Content" | mail -s "Mail Subject" 245305579@qq.com
客户端配置
服务器类型:`POP3`
邮箱账户: `test@yourdomain.com`
收件(POP3)服务器: `yourdomain.com`
端口: `995`
安全连接(SSL): `是`
用户名: `test`
密码: `test用户密码`
发件(SMTP)服务器: `yourdomain.com`
端口: `465`
安全连接(SSL): `是`
用户名: `test`
密码: `test用户密码`
域名准备
echo "我是张少龙" | mail -s "我想做运维" 245305579@qq.com
dns注意使用223.5.5.5 如果使用8.8.8.8可能因为dns问题无法收到邮件 主机上主机名一定要按要求配置 deyi.mail.zhangsl.xyz
如果是根域名
mail.zhangsl.xyz
https://cloud.tencent.com/developer/labs/lab/10096
内网时需要自建dns
后面参考
https://blog.csdn.net/qq_35263061/article/details/60577530