Sunday, December 29, 2024
Google search engine
HomeGuest BlogsHow To Install Postfix 3 on CentOS 7 / RHEL 7

How To Install Postfix 3 on CentOS 7 / RHEL 7

This guide will take you through the steps of Installing postfix3 on CentOS 7 / RHEL 7. Before diving to installation of postfix 3 on CentOS 7, let’s first define what’s postfix.

What is Postfix?

Postfix, designed by Wietse Venema, is a mail server built with security in mind and specifically designed to replace Sendmail. Postfix is a free and open-source mail transfer agent (MTA) that routes and delivers electronic mail.

There are several different components to the email system which work together to move, deliver or retrieve your email. These includes but not limited to:

  • Mail Transfer Agent (MTA)
  • Mail Delivery Agent (MDA)
  • Mail User Agent (MUA)

Postfix has several hundred configuration parameters that are controlled via the main.cf  file.

Adding Postfix 3 repository to CentOS 7 / RHEL 7

Enable EPEL repository

sudo yum -y install epel-release yum-utils

Add Ghettoforge repository to your CentOS 7 system:

sudo yum --nogpg install https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm

Hit the Y key in your keyboard to proceed with repository addition:

Examining /var/tmp/yum-root-ybrf7D/gf-release-latest.gf.el7.noarch.rpm: gf-release-7-12.gf.el7.noarch
Marking /var/tmp/yum-root-ybrf7D/gf-release-latest.gf.el7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package gf-release.noarch 0:7-12.gf.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

======================================================================================================================================================================================================
 Package                                    Arch                                   Version                                     Repository                                                        Size
======================================================================================================================================================================================================
Installing:
 gf-release                                 noarch                                 7-12.gf.el7                                 /gf-release-latest.gf.el7.noarch                                 4.5 k

Transaction Summary
======================================================================================================================================================================================================
Install  1 Package

Total size: 4.5 k
Installed size: 4.5 k
Is this ok [y/d/N]: y

Confirm repository is added successfully:

$ sudo yum repolist
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                                           |  15 kB  00:00:00
 * base: nyc.mirrors.clouvider.net
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: us.mirror.nsec.pt
 * updates: mirror.umd.edu
epel                                                                                                                                                                           | 4.7 kB  00:00:00
gf                                                                                                                                                                             | 2.9 kB  00:00:00
(1/4): epel/x86_64/updateinfo                                                                                                                                                  | 1.0 MB  00:00:00
(2/4): epel/x86_64/group_gz                                                                                                                                                    |  96 kB  00:00:00
(3/4): epel/x86_64/primary_db                                                                                                                                                  | 7.0 MB  00:00:00
(4/4): gf/x86_64/primary_db                                                                                                                                                    |  52 kB  00:00:00
repo id                                                                   repo name                                                                                                             status
base/7/x86_64                                                             CentOS-7 - Base                                                                                                       10072
droplet-agent/x86_64                                                      DigitalOcean Droplet Agent                                                                                                5
epel/x86_64                                                               Extra Packages for Enterprise Linux 7 - x86_64                                                                        13667
extras/7/x86_64                                                           CentOS-7 - Extras                                                                                                       500
gf/x86_64                                                                 Ghettoforge packages that won't overwrite core distro packages.                                                          86
updates/7/x86_64                                                          CentOS-7 - Updates                                                                                                     2747
repolist: 27077

Install Postfix 3 repository to CentOS 7 / RHEL 7

Enable gf-plus repository:

sudo yum-config-manager --enable gf-plus

Test by searching postfix3 packages:

$ sudo yum search postfix3
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: nyc.mirrors.clouvider.net
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: us.mirror.nsec.pt
 * updates: mirror.umd.edu
======================================================================================= N/S matched: postfix3 ========================================================================================
postfix3.x86_64 : Postfix Mail Transport Agent
postfix3-cdb.x86_64 : CDB Database Support for Postfix
postfix3-ldap.x86_64 : LDAP Database Support for Postfix
postfix3-lmdb.x86_64 : LMDBtabase Support for Postfix
postfix3-mysql.x86_64 : MySQL Database Support for Postfix
postfix3-pcre.x86_64 : PCRE Database Support for Postfix
postfix3-pgsql.x86_64 : PostgreSQL Database Support for Postfix
postfix3-sqlite.x86_64 : SQLite Database Support for Postfix
postfix3-utils.x86_64 : Postfix utilities

  Name and summary matches only, use "search all" for everything

Remove current postfix 2.x version if installed:

sudo yum -y remove postfix*

Proceed to Installing postfix3 on CentOS 7. Add any additional packages you want.

sudo yum clean all
sudo yum makecache
sudo yum install postfix3 postfix3-ldap postfix3-mysql postfix3-utils

Continue with the installation:

....
Dependencies Resolved
....
Transaction Summary
======================================================================================================================================================================================================
Install  4 Packages (+32 Dependent packages)

Total download size: 23 M
Installed size: 75 M
Is this ok [y/d/N]: y

Ensure you import GPG keys when asked so:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                 8.0 MB/s |  23 MB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
Importing GPG key 0xDA8B7718:
 Userid     : "Ghettoforge (el7) <[email protected]>"
 Fingerprint: b43e a892 86f4 b6fd ff83 fed1 d005 ae31 da8b 7718
 Package    : gf-release-7-12.gf.el7.noarch (@/gf-release-latest.gf.el7.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
Is this ok [y/N]: y

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <[email protected]>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y

Check installed postfix3 version:

$ rpm -qi postfix3
Name        : postfix3
Epoch       : 2
Version     : 3.8.0
Release     : 1.gf.el7
Architecture: x86_64
Install Date: Tue 06 Jun 2023 01:45:57 AM UTC
Group       : System Environment/Daemons
Size        : 10293012
License     : IBM
Signature   : RSA/SHA1, Tue 18 Apr 2023 09:20:05 AM UTC, Key ID d005ae31da8b7718
Source RPM  : postfix3-3.8.0-1.gf.el7.src.rpm
Build Date  : Tue 18 Apr 2023 09:16:19 AM UTC
Build Host  : giants.ghettoforge.org
Relocations : (not relocatable)
Packager    : [email protected]
Vendor      : GhettoForge
....

Managing postfix3 service

To start postfix3 on CentOS 7, do:

sudo systemctl start postfix.service

Enable postfix to start on boot up:

sudo systemctl enable postfix

Check postfix status:

$ systemctl status postfix
 postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-06-06 01:46:54 UTC; 7s ago
 Main PID: 2615 (master)
   CGroup: /system.slice/postfix.service
           ├─2615 /usr/libexec/postfix/master -w
           ├─2616 pickup -l -t unix -u
           └─2617 qmgr -l -t unix -u

Jun 06 01:46:53 cent7.mylab.io systemd[1]: Starting Postfix Mail Transport Agent...
Jun 06 01:46:54 cent7.mylab.io postfix[2541]: postfix/postlog: starting the Postfix mail system
Jun 06 01:46:54 cent7.mylab.io postfix/master[2615]: daemon started -- version 3.8.0, configuration /etc/postfix
Jun 06 01:46:54 cent7.mylab.io systemd[1]: Started Postfix Mail Transport Agent.

Open postfix smtp and smtps ports on firewall if SMTP service is consumed outside the server

sudo firewall-cmd --add-service={smtp,smtps} --permanent

Confirm firewall configurations:

$ sudo firewall-cmd --list-services 
http smtp dhcpv6-client snmp smtps ssh https

Now you are rolling with Postfix3 on your CentOS 7 server. In our next tutorial, I’ll cover how to integrate LDAP and postfix for relay access restrictions. Until then, keep checking for new articles and subscribe to our email alerts.

After installing Postfix, you can look at my cheat sheet on Postfix administration:

More guides on mail services:

RELATED ARTICLES

Most Popular

Recent Comments