From 13f540c772154f5aa88030d84450f7620d453477 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Thu, 21 Nov 2019 07:29:15 +0800 Subject: [PATCH] PRF @geekpi --- ...nfigure Postfix Mail Server on CentOS 8.md | 94 +++++++++---------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md b/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md index 66452903ae..ccfccd6297 100644 --- a/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md +++ b/translated/tech/20191113 How to install and Configure Postfix Mail Server on CentOS 8.md @@ -1,6 +1,6 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to install and Configure Postfix Mail Server on CentOS 8) @@ -10,9 +10,9 @@ 如何在 CentOS 8 上安装和配置 Postfix 邮件服务器 ====== -**Postfix** 是一个免费的开源 **MTA**(邮件传输代理),用于在 Linux 系统上路由或传递电子邮件。在本指南中,你将学习如何在 CentOS 8 上安装和配置 Postfix。 +Postfix 是一个自由开源的 MTA(邮件传输代理),用于在 Linux 系统上路由或传递电子邮件。在本指南中,你将学习如何在 CentOS 8 上安装和配置 Postfix。 -[![Install-configure-Postfx-Server-CentOS8][1]][2] +![Install-configure-Postfx-Server-CentOS8][2] 实验室设置: @@ -20,8 +20,6 @@ * IP 地址:192.168.1.13 * 主机名:server1.crazytechgeek.info(确保域名指向服务器的 IP) - - ### 步骤 1)更新系统 第一步是确保系统软件包是最新的。为此,请按如下所示更新系统: @@ -30,7 +28,7 @@ # dnf update ``` -继续之前,还请确保不存在其他 **MTA**(如 **Sendmail**),因为这将导致与 Postfix 配置冲突。例如,要删除 Sendmail,请运行以下命令: +继续之前,还请确保不存在其他 MTA(如 Sendmail),因为这将导致与 Postfix 配置冲突。例如,要删除 Sendmail,请运行以下命令: ``` # dnf remove sendmail @@ -38,14 +36,14 @@ ### 步骤 2)设置主机名并更新 /etc/hosts -使用下面的 hostnamectl 命令在系统上设置主机名, +使用下面的 `hostnamectl` 命令在系统上设置主机名: ``` # hostnamectl set-hostname server1.crazytechgeek.info # exec bash ``` -此外,你需要在 /etc/hosts 中添加系统的主机名和 IP。 +此外,你需要在 `/etc/hosts` 中添加系统的主机名和 IP: ``` # vim /etc/hosts @@ -62,7 +60,7 @@ # dnf install postfix ``` -[![Install-Postfix-Centos8][1]][3] +![Install-Postfix-Centos8][3] ### 步骤 4)启动并启用 Postfix 服务 @@ -73,29 +71,29 @@ # systemctl enable postfix ``` -要检查 Postfix 状态,请运行以下 systemctl 命令 +要检查 Postfix 状态,请运行以下 `systemctl` 命令: ``` # systemctl status postfix ``` -![Start-Postfix-check-status-centos8][1] +![Start-Postfix-check-status-centos8][9] 太好了,我们已经验证了 Postfix 已启动并正在运行。接下来,我们将配置 Postfix 从本地发送邮件到我们的服务器。 ### 步骤 5)安装 mailx 邮件客户端 -在配置 Postfix 服务器之前,我们需要安装 mailx,要安装它,请运行以下命令: +在配置 Postfix 服务器之前,我们需要安装 `mailx`,要安装它,请运行以下命令: ``` # dnf install mailx ``` -![Install-Mailx-CentOS8][1] +![Install-Mailx-CentOS8][10] ### 步骤 6)配置 Postfix 邮件服务器 -Postfix 的配置文件位于 **/etc/postfix/main.cf** 中。我们需要对配置文件进行一些修改,因此请使用你喜欢的文本编辑器将其打开。 +Postfix 的配置文件位于 `/etc/postfix/main.cf` 中。我们需要对配置文件进行一些修改,因此请使用你喜欢的文本编辑器将其打开: ``` # vi /etc/postfix/main.cf @@ -121,7 +119,7 @@ mynetworks = 192.168.1.0/24, 127.0.0.0/8 home_mailbox = Maildir/ ``` -完成后,保存并退出配置文件。重新启动 postfix 服务以使更改生效。 +完成后,保存并退出配置文件。重新启动 postfix 服务以使更改生效: ``` # systemctl restart postfix @@ -136,7 +134,7 @@ home_mailbox = Maildir/ # passwd postfixuser ``` -接下来,运行以下命令,从本地用户 **pkumar** 发送邮件到另一个用户 “**postfixuser**”。 +接下来,运行以下命令,从本地用户 `pkumar` 发送邮件到另一个用户 `postfixuser`。 ``` # telnet localhost smtp @@ -181,7 +179,7 @@ Escape character is '^]'. 250 SMTPUTF8 ``` -接下来,运行橙色高亮的命令,例如 “mail from”、“rcpt to”,“data”,最后输入 “quit”, +接下来,运行橙色高亮的命令,例如 `mail from`、`rcpt to`、`data`,最后输入 `quit`: ``` mail from: @@ -198,11 +196,11 @@ quit Connection closed by foreign host ``` -完成 telnet 命令可从本地用户 “**pkumar**” 发送邮件到另一个本地用户 “**postfixuser**”,如下所示: +完成 `telnet` 命令可从本地用户 `pkumar` 发送邮件到另一个本地用户 `postfixuser`,如下所示: -![Send-email-with-telnet-centos8][1] +![Send-email-with-telnet-centos8][11] -如果一切都按计划进行,那么你应该可以在新用户的家目录中查看发送的邮件。 +如果一切都按计划进行,那么你应该可以在新用户的家目录中查看发送的邮件: ``` # ls /home/postfixuser/Maildir/new @@ -216,37 +214,37 @@ Connection closed by foreign host # cat /home/postfixuser/Maildir/new/1573580091.Vfd02I20050b8M635437.server1.crazytechgeek.info ``` -![Read-postfix-email-linux][1] +![Read-postfix-email-linux][12] ### Postfix 邮件服务器日志 -Postfix 邮件服务器邮件日志保存在文件 “**/var/log/maillog**” 中,使用以下命令查看实时日志, +Postfix 邮件服务器邮件日志保存在文件 `/var/log/maillog` 中,使用以下命令查看实时日志, ``` # tail -f /var/log/maillog ``` -![postfix-maillogs-centos8][1] +![postfix-maillogs-centos8][13] ### 保护 Postfix 邮件服务器 -建议始终确保客户端和 postfix 服务器之间的通信安全,这可以使用 SSL 证书来实现,它们可以来自受信任的权威机构或自签名证书。在本教程中,我们将使用 **openssl** 命令生成用于 postfix 的自签名证书, +建议始终确保客户端和 Postfix 服务器之间的通信安全,这可以使用 SSL 证书来实现,它们可以来自受信任的权威机构或自签名证书。在本教程中,我们将使用 `openssl` 命令生成用于 Postfix 的自签名证书, -我假设 openssl 已经安装在你的系统上,如果未安装,请使用以下 dnf 命令, +我假设 `openssl` 已经安装在你的系统上,如果未安装,请使用以下 `dnf` 命令: ``` # dnf install openssl -y ``` -使用下面的 openssl 命令生成私钥和 CSR(证书签名请求), +使用下面的 `openssl` 命令生成私钥和 CSR(证书签名请求): ``` # openssl req -nodes -newkey rsa:2048 -keyout mail.key -out mail.csr ``` -![Postfix-Key-CSR-CentOS8][1] +![Postfix-Key-CSR-CentOS8][14] -现在,使用以下 openssl 命令生成自签名证书, +现在,使用以下 openssl 命令生成自签名证书: ``` # openssl x509 -req -days 365 -in mail.csr -signkey mail.key -out mail.crt @@ -256,13 +254,13 @@ Getting Private key # ``` -现在将私钥和证书文件复制到 /etc/postfix 目录下。 +现在将私钥和证书文件复制到 `/etc/postfix` 目录下: ``` # cp mail.key mail.crt /etc/postfix ``` -在 postfix 配置文件中更新私钥和证书文件的路径 +在 Postfix 配置文件中更新私钥和证书文件的路径: ``` # vi /etc/postfix/main.cf @@ -274,21 +272,21 @@ smtpd_tls_security_level = may ……… ``` -重启 postfix 服务以使上述更改生效。 +重启 Postfix 服务以使上述更改生效: ``` # systemctl restart postfix ``` -让我们尝试使用 mailx 客户端将邮件发送到内部本地域和外部域。 +让我们尝试使用 `mailx` 客户端将邮件发送到内部本地域和外部域。 -**从 pkumar 发送内部本地邮件到 postfixuser 中** +从 `pkumar` 发送内部本地邮件到 `postfixuser` 中: ``` # echo "test email" | mailx -s "Test email from Postfix MailServer" -r root@linuxtechi root@linuxtechi ``` -使用以下命令检查并阅读邮件, +使用以下命令检查并阅读邮件: ``` # cd /home/postfixuser/Maildir/new/ @@ -299,19 +297,19 @@ total 8 # cat 1573612845.Vfd02I20050bbM466643.server1.crazytechgeek.info ``` -![Read-Postfixuser-Email-CentOS8][1] +![Read-Postfixuser-Email-CentOS8][15] -**从 postfixuser 发送邮件到外部域 (( [root@linuxtechi][4]))** +从 `postfixuser` 发送邮件到外部域(`root@linuxtechi.com`): ``` # echo "External Test email" | mailx -s "Postfix MailServer" -r root@linuxtechi root@linuxtechi ``` -**注意:** 如果你的 IP 没有被任何地方列入黑名单,那么你发送到外部域的邮件将被发送,否则它将被退回,并提示你的 IP 被 spamhaus 之类的数据库列入黑名单。 +注意:如果你的 IP 没有被任何地方列入黑名单,那么你发送到外部域的邮件将被发送,否则它将被退回,并提示你的 IP 被 spamhaus 之类的数据库列入黑名单。 ### 检查 Postfix 邮件队列 -使用mailq命令列出队列中的邮件。 +使用 `mailq` 命令列出队列中的邮件: ``` # mailq @@ -321,13 +319,6 @@ Mail queue is empty 完成!我们的 Postfix 配置正常工作了!目前就这样了。我们希望你觉得本教程有见地,并且你可以轻松地设置本地 Postfix 服务器。 - * [Facebook][5] - * [Twitter][6] - * [LinkedIn][7] - * [Reddit][8] - - - -------------------------------------------------------------------------------- via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ @@ -335,7 +326,7 @@ via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ 作者:[James Kiarie][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -345,7 +336,10 @@ via: https://www.linuxtechi.com/install-configure-postfix-mailserver-centos-8/ [2]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-configure-Postfx-Server-CentOS8.jpg [3]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Postfix-Centos8.png [4]: https://www.linuxtechi.com/cdn-cgi/l/email-protection -[5]: http://www.facebook.com/sharer.php?u=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&t=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 -[6]: http://twitter.com/share?text=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&via=Linuxtechi -[7]: http://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&title=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 -[8]: http://www.reddit.com/submit?url=https%3A%2F%2Fwww.linuxtechi.com%2Finstall-configure-postfix-mailserver-centos-8%2F&title=How%20to%20install%20and%20Configure%20Postfix%20Mail%20Server%20on%20CentOS%208 +[9]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Start-Postfix-check-status-centos8.png +[10]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Install-Mailx-CentOS8.png +[11]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Send-email-with-telnet-centos8.png +[12]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-postfix-email-linux.png +[13]: https://www.linuxtechi.com/wp-content/uploads/2019/11/postfix-maillogs-centos8.png +[14]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Postfix-Key-CSR-CentOS8.png +[15]: https://www.linuxtechi.com/wp-content/uploads/2019/11/Read-Postfixuser-Email-CentOS8.png