第1步:在Ubuntu上安装Postfix
Ubuntu默认存储库提供了Postfix软件包。
安装PostFix:
sudo apt update sudo apt install postfix
在安装过程中,系统会提示我们通过选择其配置站点和邮件系统名称或者域名选择Postfix配置
Package configuration ┌───────────────────────────┤ Postfix Configuration ├───────────────────────────┐ │ Please select the mail server configuration type that best meets your needs. │ │ │ │ No configuration: │ │ Should be chosen to leave the current configuration unchanged. │ │ Internet site: │ │ Mail is sent and received directly using SMTP. │ │ Internet with smarthost: │ │ Mail is received directly using SMTP or by running a utility such │ │ as fetchmail. Outgoing mail is sent using a smarthost. │ │ Satellite system: │ │ All mail is sent to another machine, called a 'smarthost', for delivery. │ │ Local only: │ │ The only delivered mail is the mail for local users. There is no network. │ │ │ │ General type of mail configuration: │ │ │ │ No configuration │ │ Internet Site │ │ Internet with smarthost │ │ Satellite system │ │ Local only │ │ │ │ <Ok> <Cancel> │ │ │ └───────────────────────────────────────────────────────────────────────────────┘
出现提示时,选择上面突出显示的Internet站点。
接下来选择邮件系统的域名:
┌─────────────────────────────────────────┤ Postfix Configuration ├──────────────────────────────────────────┐ │ The "mail name" is the domain name used to "qualify" _ALL_ mail addresses without a domain name. This │ │ includes mail to and from : please do not make your machine send out mail from root@example.org │ │ unless root@example.org has told you to. │ │ │ │ This name will also be used by other programs. It should be the single, fully qualified domain name │ │ (FQDN). │ │ │ │ Thus, if a mail address on the local host is foo@example.org, the correct value for this option would be │ │ example.org. │ │ │ │ System mail name: │ │ │ │ maill.example.com_________________________________________________________________________________________ │ │ │ │ <Ok> <Cancel> │ │ │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
安装完成后,我们可以使用以下命令停止,启动和启用该服务:
sudo systemctl stop postfix sudo systemctl start postfix sudo systemctl enable postfix
第2步:配置Postfix
Postfix主要配置文件位于/etc/postfix/main.cf
打开其默认配置文件:
sudo nano /etc/postfix/main.cf
大多数Postfix的设置可以在此配置文件中找到。
在文件的底部,您可以找到所有设置环境所需的配置选项。
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = ubuntu1804.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myoroirn = /etc/mailname mydestination = $myhostname, mail.example.com, ubuntu1804, localhost.localdomain, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = all
有三到四个主要的配置选项:MyHostName,MyDestination,MyNetworks和Mail Home文件夹。
这些是上面一些配置的详细信息:
myhostnme:介绍邮件服务器主机名或者系统名称。通常是其完全限定的主机名。例如: mailsr.example.com.
Mydomain:描述Postfix 处理邮件的域名,示例:example.com.
MyNetWorks:介绍可以通过服务器中继的远程SMTP服务器的可信网络,例如:127.0.0.0/8 [::ffff:127.0.0.0]/104 [:: 1]/128
Home_mailbx:描述了用户的主邮箱。 例如:home_mailbox = maildir /
除了上面的配置选项,Postfix还附带了系统上配置的自签名证书设置。
Postfix自签名SSL证书设置位于上面提到的相同配置文件中。
TLS配置行看起来像这样:
# TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes
其他Postfix配置位于/etc/postfix目录中。
日期:2020-07-07 20:55:21 来源:oir作者:oir