How To Configure Postfix Server and Mail Aliases In RHEL-6 OR CentOs-6

Postfix is fast and popular SMTP server widely used. The main job of postfix is to relay mail locally or to intended destination outside the network. Some of the most popular SMTP servers are Sendmail, Postfix and Qmail. By default Sendmail comes pre-installed with CentOS/RHEL 5. We will need need to remove it and install Postfix. On CentOS/RHEL 6 ‘postfix’ are installed by default, so there are no need to install it

Mail Process-

MTA-     Mail Transfer Agent

MDA-    Mail Delivery Agent
MUA-    Mail User Agent
MRA-    Mail Retiveral Agent
MAA-    Mail Access Agent

Package-        Postfix
Port No -        25 [smtp]
Script-            /etc/init.d/postfix
Daemon-        Postfix
Config file-    /etc/postfix/

Note- Before install postfix, remove sendmail from the server. Because sendmail is the default MTA in Redhat/CentOS.

[root@server ~]# yum remove sendmail

 1- The mail server should contain a valid MX record in the DNS server. Navigate to this link how to setup DNS server.

2- Firewall and SELinux should be disabled.

[root@server ~]# service iptables stop
[root@server ~]# service ip6tables stop
[root@server ~]# chkconfig iptables off
[root@server ~]# chkconfig ip6tables off

[root@server ~]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.


Reboot the server.


Hostname     =
IP Address    =

And my server is configured with proper MX record in DNS server.


Step-1 First Install postfix Packege

[root@server ~]# yum install postfix

Step-2 Configuration
[root@server ~]# vim /etc/postfix/

myhostname =  -->line no 75 - uncomment and enter your host name
mydomain =
-->line no 83 - uncomment and enter your domain name myorigin = $mydomain  -->line no 99 - uncomment
inet_interfaces = all
-->line no 116 - change to all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 
-->line no 164 - add $domain at the end
mynetworks =, 
-->line no 264 - uncomment and add your network range
home_mailbox = Maildir/ 
-->line no 419 - uncomment


Step-3 Start the postfix service.

[root@server ~]# service postfix start
Starting postfix:                                          [  OK  ]
[root@server ~]# chkconfig postfix on

Step-4  Create a User..

[root@server ~]# useradd test-1

[root@server ~]# passwd test-1

Changing password for user test-1.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

Step-5 Check Mail
[root@server ~]# mail
Subject: Hi,
This is the testing mail by mail server {ctrl-d 2 times for save]

[root@server ~]#
su test-1

[test-1@server ~]$ mail

Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N  1 root              Sun Aug 19 16:57  18/597   "hi"
& 1
Message  1:
From  Thu May 28 16:57:53 2012
Return-Path: <>
Date: Sun, 28 May 2014 16:57:53 +0530
Subject: hi
User-Agent: Heirloom mailx 12.4 7/28/05
Content-Type: text/plain; charset=us-ascii
From: (root)
Status: R

This is the testing mail by mail server.
& exit
You have mail in /var/spool/mail/root

[test-1@server ~]$ exit

[root@server ~]#

Now Postfix Server Configuration successfully Completed.

Configure Mail Aliases-

An email alias is an email address that forwards to another email address.
For example, if your primary email address is "", you might create a second email address called "", which is easier for people to remember. Messages sent to your "" account would then be forwarded to your "" account.

The ability to create email aliases depends on your email provider. Once you have set it up (probably through your provider's website), you can configure Thunderbird to download and sort messages to your alias account in the same manner it deals with messages to your primary account.

1- Create a two user like..[root@server ~]# useradd test-1
[root@server ~]# useradd test-2
[root@server ~]# passwd test-1
[root@server ~]# passwd test-2

2- Edit ..

[root@server ~]# vim /etc/aliases 


www:            webmaster
webmaster:   root
noc:              root
security:        root
hostmaster:   root
info:              postmaster
marketing:    postmaster
sales:           postmaster
support:       postmaster
test-1:          test-2



Note- Now you will send a mail to test-1 user and it will transfer to test-2.

[root@server ~]# su - test-2

[root@server ~]# mail

( Note-It will show the mail which send by root user to test-1 user )

Click Back..                                Click Home..