Tags

Hi all, today we learn how to configure postfix server in Linux. This tutorial includes postfix configuration, installation on both localhost and website. After configuration we will test postfix server by sending mail locally to clients.

Before Postfix configuration & installation lets have an eye on important points related to Postfix server ==>

 

>Postfix is a free and open source software which is released under the IBM Public License 1.0 .

>Postfix is a fast and popular smtp server widely used.

>Postfix is an alternative to widely used Sendmail server.

>It is basicly a MTA (mail transfer agent) and its main job is to route and relay mail localy or to any outside network.

>We have to stop or remove the sendmail service before installing postfix.

>postfix is a popular smtp server so it uses port no 25 as default port.

 

Installation and Configuration of Postfix Server

 

3 steps to postfix==>

 

1 Installation

2.Configuration

3.Start postfix service

 

One can do postfix configuration within minutes, if you are beginner and don’t know how to mess with it, don’t worry after reading this tutorial you can easily do postfix configuration your own Postfix mail server.
>First of all we will remove sendmail from our system and then after we will install Postfix server with yum, after configuring it we will restart the postfix service.After installion and configuration we will test our postfix server by sending mail to clients in our linux system.

 

So let’ get started ==>

 

Step by step guide to postfix configuration

 

Step 1 >

 

first of all remove or stop sendmail service.

#yum remove sendmail

 

1

or

#service sendmail stop

2

 

Step 2 >

 

Now install Postfix with Yum.

#yum install Postfix

 

3

 

Step 3>

 

Configuration file of Postfix server is ==> /etc/postfix/main.cf

Go to postfix configuration file with your favourite file editor, i will use vim editor here.

#vim /etc/postfix/main.cf

 

4

 

If you are running a website on your postfix server then edit below entries in the postfix configuration file ==>

 

myhostname  =  mail.helpingyouonline.net

mydomain    =  helpingyouonline.net

myorigin    =  $mydomain

mydestination = $myhostname, localhost, $mydomain

inet_interfaces = all
mynetworks = 127.0.0.1/8, 192.168.20.0/24
home_mailbox = Maildir/

save the file by==> Esc:wq

 

Explanation of above entries ==>

 

myhostname  = specifies the fully-qualified domain name of the machine running the Postfix system. If you do not running a website on postfix server then the default is to use the local machine name.

 

mydomain = specifies the parent domain of $myhostname (by stripping off its first part)

 

myorigin = specifies What domain name to use in outbound mail.

 

mydestination = specifies what domains this machine will deliver locally(The default is to receive mail for the machine itself.)

 

inet_interfaces =all ==> It specifies all network interface addresses that the Postfix system should listen on.

 

mynetworks ==> here you have to input those networks which are going to use this mail server, if you are in network 192.168.20.0/24 then you have to input it in this entry.

 

home_mailbox ==> It is basically the directory where all mails will be saved.

 

If you are do not running any website on your postfix server then edit below entries in the postfix configuration file ==>

 

inet_interfaces = all
mynetworks = 127.0.0.1/8
home_mailbox = Maildir/

 

You have to change only above entries, do not mess with other entries, above entries are sufficient (if you do not running any site) to run your own postfix server.

Step 4 >

 

Now restart the postfix service.

#service postfix restart

 

5

 

Step 5>

 

Configure Postfix service to autostart on system boot

#chkconfig postfix on

 

6

 

Step 6>

 

Now let’s make postfix the default MTA(mail transfer agent) for your Linux system

 

#alternatives    –set mta   /usr/sbin/postfix

 

alt1

 

If above command doesn’t work ==>

 

#alternatives   –set mta    /usr/sbin/sendmail.postfix

 

alt2

 

Step 7 >

 

Now configure firewall (iptables) to allow postfix service.

 

#iptables  -A  INPUT  -m  state  –state  NEW  -m  tcp  -p  tcp  –dport  25  -j  ACCEPT

 

firewall

 

>#service iptables restart

 

So finally we have successfully configured Postfix server. As you see it’s very easy to install and configure Postfix server.

 

Read more =>

|1| Telnet server in Rhel6?

|2| Complete tutorial on SSH.

|3|User and group management.

 

Now it’s time to check our Postfix configuration==>

 

Checking Postfix server locally 

 

If you do not running any website on your postfix server then you can test your postfix configuration by sending mail localy to clients or added users.

 

add a user in your Linux system =>

#useradd   sam
#passwd   sam

 

7

 

>Now send mail to user sam to test postfix server.

 

#mail    -v   sam

 

8

 

Now check status of mail

 

#mail    -u    sam

 

9

 

So as you see mail is sent successfully.

 

now login as user sam and check mail is recieved or not=>

 

#mail

 

10

 

So as you see mail is delivered to sam successfully.

 

Final thoughts

 

So as we see our Postfix server is working properly. So today we have learned the postfix configuration& insatallation in Linux. Hope you like this article.

Do follow us if you like this article and share it on Facebook for more Linux articles.

If you any queries or doubts then lend them to comment box.