介绍 (Introduction)
Postfix is a mail transfer agent (MTA), an application used to send and receive email. It can be configured so that it can be used to send emails by local application only. This is useful in situations when you need to regularly send email notifications from your apps or have a lot of outbound traffic that a third-party email service provider won’t allow. It’s also a lighter alternative to running a full-blown SMTP server, while retaining the required functionality.
Postfix是一个邮件传输代理 (MTA),一种用于发送和接收电子邮件的应用程序。 可以对其进行配置,使其仅可用于通过本地应用程序发送电子邮件。 当您需要定期从应用程序发送电子邮件通知或第三方电子邮件服务提供商不允许的大量出站流量时,这很有用。 它是运行成熟的SMTP服务器的较轻的替代方案,同时保留了所需的功能。
In this tutorial, you’ll install and configure Postfix as a send-only SMTP server. You’ll also request free TLS certificates from Let’s Encrypt for your domain and encrypt the outbound emails using them.
在本教程中,您将安装Postfix并将其配置为仅发送SMTP服务器。 您还将向我们的域的Let's Encrypt请求免费的TLS证书,并使用它们对出站电子邮件进行加密。
先决条件 (Prerequisites)
One Ubuntu 20.04 server set up with the Initial Server Setup with Ubuntu 20.04, including creating a sudo non-root user.
一台使用Ubuntu 20.04进行初始服务器设置的Ubuntu 20.04服务器 ,包括创建sudo非root用户。
A fully registered domain name. This tutorial will use
your_domain
throughout. You can purchase a domain name on Namecheap, get one for free on Freenom, or use the domain registrar of your choice.完全注册的域名。 本教程将整个使用
your_domain
。 你可以购买一个域名Namecheap ,免费获得一个在Freenom ,或使用你选择的域名注册商。An A DNS record with
your_domain
pointing to your server’s public IP address. You can follow this introduction to DigitalOcean DNS for details on how to add them.一个A DNS记录与
your_domain
指向您的服务器的公网IP地址。 您可以按照DigitalOcean DNS简介进行操作,以获取有关如何添加它们的详细信息。
Note: Your server’s hostname and your Droplet’s name must match your_domain
, because DigitalOcean automatically sets PTR records for the Droplet’s IP address according to its name.
注意:服务器的主机名和Droplet的名称必须匹配your_domain
,因为DigitalOcean会根据其名称自动为Droplet的IP地址设置PTR记录。
You can verify the server’s hostname by typing hostname
at the command prompt. The output should match the name you gave the Droplet when it was being created.
您可以通过在命令提示符下键入hostname
来验证服务器的主机hostname
。 输出应与您在创建Droplet时提供的名称匹配。
第1步-安装Postfix (Step 1 — Installing Postfix)
In this step, you’ll install Postfix. The fastest way is to install the mailutils
package, which bundles Postfix with a few supplementary programs that you’ll use to test sending email.
在此步骤中,您将安装Postfix。 最快的方法是安装mailutils
软件包,该软件包将Postfix与一些补充程序捆绑在一起,您将使用这些补充程序来测试发送电子邮件。
First, update the package database:
首先,更新软件包数据库:
- sudo apt update sudo apt更新
Then, install Postfix by running the following command:
然后,通过运行以下命令来安装Postfix:
- sudo apt install mailutils sudo apt安装mailutils
Near the end of the installation process, you will be presented with the Postfix configuration window:
在安装过程快要结束时,将显示“ Postfix配置”窗口:
The default option is Internet Site
. That’s the recommended option for your use case, so press TAB
, and then ENTER
. If you only see the description text, press TAB<