How to Install POSTFIX on CentOS, Debian & Ubuntu?

Blog on Installing POSTFIX on CentOS, Debian & Ubuntu?

Postfix is one of the fast, secure and open source mail transfer agent which is used to relay mails locally and to remote network.

The below guide will explain how to install Postfix specifically on a different OS distribution.

Installation on CentOS7

By default, CentOS7 comes with pre-installed Sendmail MTA. So first we may need to remove the default MTA. Sendmail will not be installed by default in minimal installation, so we can skip this step if there is no sendmail installed.

1. Verify and Remove the default MTA (Sendmail)

# rpm -qa | grep sendmail
# yum remove sendmail

2. Install postfix.

# yum install postfix

3. Once the Postfix has been installed, we need to configure the postfix.

#vi /etc/postfix/main.cf

Then you may need to configure the below settings.

## Uncomment and set your mail server FQDN ##
myhostname = mail.server.com
## Uncomment and Set domain name ##
mydomain = yourdomain.com
## Uncomment ##
myorigin = $mydomain
## Uncomment and Set ipv4 ##
inet_interfaces = all
## UnComment ##
mydestination = $myhostname, localhost, $mydomain
## Uncomment and add IP range ##
mynetworks = 127.0.0.0/8, /32
## Uncomment ##
relay_domains = $mydestination

## Uncomment ##
home_mailbox = Maildir/

4. Restart Postfix Service

# systemctl enable postfix
# systemctl restart postfix

Installation on Ubuntu/Debian

Postfix packages are available under default repositories of Ubuntu operating systems.
To install Postfix SMTP server on your Ubuntu system please follow the steps:

1. Install Postfix

# sudo apt-get install postfix

The installation process will ask you for some inputs like below.

Postfix Installation guide
Postfix configuration

2. Once the Postfix has been installed, we need to configure the postfix.

#vi /etc/postfix/main.cf

Then you may need to configure the below settings.

## Uncomment and set your mail server FQDN ##
myhostname = mail.server.com
## Uncomment and Set domain name ##
mydomain = yourdomain.com
## Uncomment ##
myorigin = $mydomain
## Uncomment and Set ipv4 ##
inet_interfaces = all
## UnComment ##
mydestination = $myhostname, localhost, $mydomain
## Uncomment and add IP range ##
mynetworks = 127.0.0.0/8, /32
## Uncomment ##
relay_domains = $mydestination
## Uncomment ##
home_mailbox = Maildir/

4. Restart Postfix Service

# sudo service postfix restart

GET STARTED WITH OUR HOSTING SUPPORT SERVICES

Leave a Reply