如何在Ubuntu 20.04 LTS上安装Postfix

postfix-mail-logoUbuntu 20.04 LTS Focal Fossa上安装Postfix

步骤1.首先,通过apt在终端中运行以下命令来确保所有系统软件包都是最新的。

sudo apt update
sudo apt upgrade

步骤2.在Ubuntu 20.04上安装Postfix。

现在,我们通过运行以下命令继续安装Postfix:

sudo apt install postfix sasl2-bin

现在,将提示您选择邮件服务器配置的类型。选择继续,从该列表中选择[无配置],然后按Enter键,如下图突出显示:

+------+ Postfix Configuration +-------+
| General type of mail configuration:  |
|                                      |
|       No configuration               |
|       Internet Site                  |
|       Internet with smarthost        |
|       Satellite system               |
|       Local only                     |
|                                      |
|                                      |
|       <Ok>           <Cancel>        |
|                                      |
+--------------------------------------+

步骤3.配置Postfix。

成功安装后,现在我们编辑Postfix配置文件:

cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf
nano /etc/postfix/main.cf

添加以下行:

Add the following lines:

# line 78: uncomment

mail_owner = postfix

# line 94: uncomment and specify hostname

myhostname = mail.yundongfang.com

# line 102: uncomment and specify the domain name

mydomain = yundongfang.com

# line 123: uncomment

myorigin = $mydomain

# line 137: uncomment

inet_interfaces = all

# line 185: uncomment

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

# line 228: uncomment

local_recipient_maps = unix:passwd.byname $alias_maps

# line 270: uncomment

mynetworks_style = subnet

# line 287: add your local network

mynetworks = 127.0.0.0/8,10.0.0.0/24

# line 407: uncomment

alias_maps = hash:/etc/aliases

# line 418: uncomment

alias_database = hash:/etc/aliases

# line 440: uncomment

home_mailbox = Maildir/

# line 576: comment out and add
# smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_banner = $myhostname ESMTP
# line 650: add

sendmail_path = /usr/sbin/postfix

# line 655: add

newaliases_path = /usr/bin/newaliases

# line 660: add

mailq_path = /usr/bin/mailq

# line 666: add

setgid_group = postdrop

# line 670: comment out
#html_directory =
# line 674: comment out
#manpage_directory =
# line 679: comment out
#sample_directory =
# line 683: comment out
#

readme_directory =

# line 684: if also listen IPv6, change to [all]

inet_protocols = ipv4

# add to the end
# for example, limit an email size to 10Mmessage_size_limit = 10485760# for example, limit mailbox size to 1Gmailbox_size_limit = 1073741824# SMTP-Auth settings
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, permit_sasl_authenticated, reject

保存文件并关闭它。要应用更改,请输入命令:

newaliases
sudo systemctl restart postfix

恭喜你!您已经成功安装了Postfix。感谢您使用本教程在Ubuntu 20.04 LTS Focal Fossa系统上安装Postfix。如需其他帮助或有用信息,建议您访问Postfix官方网站

原创文章,作者:校长,如若转载,请注明出处:https://www.yundongfang.com/Yun40164.html

(0)
打赏 微信扫一扫不于多少! 微信扫一扫不于多少! 支付宝扫一扫礼轻情意重 支付宝扫一扫礼轻情意重
上一篇 2021年3月2日 上午11:30
下一篇 2021年3月3日 下午4:01

相关推荐