Steps To Install Postfix Server on Linux

Postfix Server on Linux System

Postfix Server:

Postfix server is mail server which is used to send emails from server or system. It is popular free and Open source

It is popular free and Open source Mail Transfer Agent[MTA] which can be used to send and receive an email from a Linux system.

In this article, I am going to demonstrate you how to Install Postfix server on a Linux system.

Before starting the installation process of Postfix you need to remove default Sendmail server from the system.

Use below command to remove send mail.

$ apt-get remove sendmail
$ apt-get purge sendmail

Once you removed the SendMail server, update the apt-get local package with update command.

Install Postfix Server:

The install postfix server is an easy process because the postfix application is available in default package repository.

$ apt-get update
$ apt-get install postfix

When you enter the install command, it will ask you about what type of mail configuration you want on the system. Choose option “internet site“.

On next step, it will ask you for FQDN [Full qualified domain name]. As we install postfix server on local system then use the hostname of your system.
If you do not want to use default hostname then change it from /etc/hostname file. Use this hostname to complete the installation process.

postfix 1

Here installation process of postfix has been completed. Now we need to configure postfix to send and receive mail from the system.

Important postfix configuration files:

Basically postfix configuration files resides under “/etc/postfix” directory. Below are the two main configuration files use to configure postfix server.


Configure Postfix:

We need to change some configuration in configuration file. These changes help to run postfix without issues.

Open “” file which is reside under “/etc/postfix” and make below provided changes on file.

[root@server ~]# vi /etc/postfix/
myhostname = hostname #This is your system hostname
mydestination = hostname, localhost.localdomain, , localhost #First would your system hostname.
inet_interfaces = all #line no. 39 uncomment this line if commented.

Restart Postfix Server:

Once the configuration changes have done, you need to restart the postfix service to take effect of configuration changes.
Run below command to restart postfix service.

$ /etc/init.d/postfix restart
$ /etc/init.d/postfix stop|start

Test Postfix configuration:

Now test your configuration by sending email from the system. use below steps to send email from the local system.
enter the bold field as per your requirement.

prashant@prashant: $ telnet localhost 25
Connected to localhost.
Escape character is '^]'.
220 prashant ESMTP Postfix (Ubuntu)
ehlo localhost
250-SIZE 10240000
250 DSN
mail from:
250 2.1.0 Ok
rcpt to:
250 2.1.5 Ok
354 End data with .
Testing postfix server --> email message
. --> To close the mail
250 2.0.0 Ok: queued as D4CF62CC3A20
^] --> Cntrl+]--> Enter

telnet> quit
Connection closed.

Now check mail on provided receive email id if you don’t find an email in inbox then check Spam Folder. We are using basic postfix configuration and also we are sending email from a local system which is not authorized. Because of this most of your email should be land in Spam directory.

That’s it.  I hope you like the article if you find any difficulties using this article then please do comment your queries or problem via the comment section, till then stay tuned to for more such valuable articles.

Leave a Reply

Your email address will not be published. Required fields are marked *