Install Postfix

Install Postfix to configure SMTP server.

[1] Install Postfix.

[[email protected] ~]# dnf install postfix -y

[2] This example shows to configure SMTP-Auth to use Dovecot's SASL function.

[[email protected] ~]# vi /etc/postfix/main.cf

# line 95: uncomment and specify hostname
myhostname = mail.futurelinux.org

# line 102: uncomment and specify domain name
mydomain = futurelinux.org

# line 118: uncomment
myorigin = $mydomain

# line 135: change
inet_interfaces = all

# line 138: change it if use only IPv4
inet_protocols = ipv4

# line 183: add
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

# line 283: uncomment and specify your local network
mynetworks = 127.0.0.0/8, 10.0.0.0/24

# line 438: uncomment (use Maildir)
home_mailbox = Maildir/

# line 591: add
smtpd_banner = $myhostname ESMTP

# add follows to the end
# limit an email size for 10M
message_size_limit = 10485760

# limit a mailbox for 1G
mailbox_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

[[email protected] ~]# systemctl enable postfix
[[email protected] ~]# systemctl start postfix

[3] On systems with SELinux active, the service may give NAMESPACE error. To fix this:

[[email protected] ~]# vi /usr/lib/systemd/system/postfix.service

# line 12 and 13 comment
#ProtectSystem=true
#PrivateDevices=true

[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart postfix

[4] If Firewalld is running, allow SMTP service. SMTP uses 25/TCP.

[[email protected] ~]# firewall-cmd --permanent --add-service=smtp
success
[[email protected] ~]# firewall-cmd --reload
success