如何在 CentOS 8 上安装和配置 Postfix 邮件服务器( 二 )


完成 telnet 命令可从本地用户 pkumar 发送邮件到另一个本地用户 postfixuser , 如下所示:

如何在 CentOS 8 上安装和配置 Postfix 邮件服务器

文章插图
Send-email-with-telnet-centos8
如果一切都按计划进行 , 那么你应该可以在新用户的家目录中查看发送的邮件:
# ls /home/postfixuser/Maildir/new 1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info #
要阅读邮件 , 只需使用 cat 命令 , 如下所示:
# cat /home/postfixuser/Maildir/new/1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info
如何在 CentOS 8 上安装和配置 Postfix 邮件服务器

文章插图
Read-postfix-email-linux
Postfix 邮件服务器日志
Postfix 邮件服务器邮件日志保存在文件 /var/log/maillog 中 , 使用以下命令查看实时日志 , 
# tail -f /var/log/maillog
如何在 CentOS 8 上安装和配置 Postfix 邮件服务器

文章插图
postfix-maillogs-centos8
保护 Postfix 邮件服务器
建议始终确保客户端和 Postfix 服务器之间的通信安全 , 这可以使用 SSL 证书来实现 , 它们可以来自受信任的权威机构或自签名证书 。在本教程中 , 我们将使用 openssl 命令生成用于 Postfix 的自签名证书 , 
我假设 openssl 已经安装在你的系统上 , 如果未安装 , 请使用以下 dnf 命令:
# dnf install openssl -y
【如何在 CentOS 8 上安装和配置 Postfix 邮件服务器】使用下面的 openssl 命令生成私钥和 CSR(证书签名请求):
# openssl req -nodes -newkey rsa:2048 -keyout mail.key -out mail.csr
如何在 CentOS 8 上安装和配置 Postfix 邮件服务器

文章插图
Postfix-Key-CSR-CentOS8
现在 , 使用以下 openssl 命令生成自签名证书:
# openssl x509 -req -days 365 -in mail.csr -signkey mail.key -out mail.crt Signature ok subject=C = IN, ST = New Delhi, L = New Delhi, O = IT, OU = IT, CN = server1.crazytechgeek.info, emailAddress = root@linuxtechi Getting Private key #
现在将私钥和证书文件复制到 /etc/postfix 目录下:
# cp mail.key mail.crt /etc/postfix
在 Postfix 配置文件中更新私钥和证书文件的路径:
# vi /etc/postfix/main.cf ……… smtpd_use_tls = yes smtpd_tls_cert_file = /etc/postfix/mail.crt smtpd_tls_key_file = /etc/postfix/mail.key smtpd_tls_security_level = may ………
重启 Postfix 服务以使上述更改生效:
# systemctl restart postfix
让我们尝试使用 mailx 客户端将邮件发送到内部本地域和外部域 。
从 pkumar 发送内部本地邮件到 postfixuser 中:
# echo "test email" | mailx -s "Test email from Postfix MailServer" -r root@linuxtechi root@linuxtechi
使用以下命令检查并阅读邮件:
# cd /home/postfixuser/Maildir/new/ # ll total 8 -rw-------. 1 postfixuser postfixuser 476 Nov 12 17:34 1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info -rw-------. 1 postfixuser postfixuser 612 Nov 13 02:40 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info # cat 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info
如何在 CentOS 8 上安装和配置 Postfix 邮件服务器

文章插图
Read-Postfixuser-Email-CentOS8
从 postfixuser 发送邮件到外部域(root@linuxtechi.com):
# echo "External Test email" | mailx -s "Postfix MailServer" -r root@linuxtechi root@linuxtechi
注意:如果你的 IP 没有被任何地方列入黑名单 , 那么你发送到外部域的邮件将被发送 , 否则它将被退回 , 并提示你的 IP 被 spamhaus 之类的数据库列入黑名单 。
检查 Postfix 邮件队列
使用 mailq 命令列出队列中的邮件:
# mailq Mail queue is empty #
完成!我们的 Postfix 配置正常工作了!目前就这样了 。我们希望你觉得本教程有见地 , 并且你可以轻松地设置本地 Postfix 服务器 。
via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/
作者: James Kiarie 选题: lujun9972 译者: geekpi 校对: wxy
本文由 LCTT 原创编译 ,  Linux中国 荣誉推出




推荐阅读