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

Rohith Krishnan

Rohith SK is an MSC computer science graduate living in Cochin, Kerala. As a technology enthusiast, he is always on the lookout for the latest trends and developments in the field, with a particular interest in cloud computing and DevOps updates. Apart from his passion for technology, Rohith SK is an avid reader and enjoys spending his free time exploring different genres of literature. He believes that reading is one of the best ways to expand one's knowledge and understanding of the world. With his expertise in computer science and a passion for technology, Rohith SK regularly contributes articles and blog posts on the latest trends and updates in the industry. His articles offer insights and valuable perspectives on the various aspects of cloud computing and DevOps, and are widely read and appreciated by readers all over the world. As an experienced technology writer and researcher, Rohith SK's articles are well-researched, informative, and easy to understand, making them accessible to readers of all levels of technical knowledge. Whether you're a beginner looking to learn more about the latest trends in technology, or an experienced professional seeking insights and updates, Rohith's articles are sure to provide valuable information and insights.

Leave a Reply