Monday, May 20, 2013

Configure Your Linux Server as Postfix Mailing gateway in step by Step

Set Up Postfix as Email server Step by step:
1 For this tutorial I have used following software:
I OS- Linux Cent OS 5.4
II. Fetch mail 6.3  to retrieve email from remote server
III Postfix 2.3.3  as MDA
IV Dovecot /IMAP
V Squirrelmail as webmail
VI MS Outlook as email clinet program

Step-I .Install Redhat Enterprise Linux or Centos then install above listed package as explained below
[root@satishmalanch ~]# yum install postfix

[root@satishmalanch ~]# yum install  fetchmail
[root@satishmalanch ~]# yum install dovecot

[root@satishmalanch ~]# yum install squirrelmail

If you are not able to install squirrelmail with yum then you can download it from and detail procedure to install is also mentioned.

Now in my scenario my server IP will be and it will retrieve the email from an external server local host name is mail.satishmalanch.local
My domain name is :satishmalanch.local

Step II Edit file
Insert following code in /etc/postfix/

#------------------------------Satish Kr Malanch   Code begin here------------------------
myhostname = mail.satishmalanch.local
mydomain = satishmalanch.local
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains = $mydestination
#configuration for SMTP authentication
#relayhost = []
#smtp_sasl_auth_enable = yes
#smtp_sasl_security_options = noanonymous
#smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
canonical_maps = hash:/etc/postfix/canonical
virtual_alias_maps = hash:/etc/postfix/virtual
smtp_generic_maps = hash:/etc/postfix/generic
home_mailbox = Maildir/
mynetworks =,,,,,,
relayhost =
#------------------------------Satish Kr Malanch   Code code end here------------------------

Step-III: Now  create a file sasl_passwd and enter mail server address username and password then save
Vim /etc/sasl_passwd

This is For authentication to external server
Step-IV  Open /etc/postfix/canonical and enter

Step-V Open /etc/postfix/generic and enter


Step-VI Open /etc/postfix/virtual user1 user2

 Now on terminal enter following commands:

postmap hash:/etc/postfix/canonical
postmap hash:/etc/postfix/generic
postmap hash:/etc/postfix/virtual
postmap hash:/etc/sasl_passwd

Step-VIITo retrieve mails from external server create a fetchmail file
Vim /home/mail_admin/fetchmailrc
        proto pop3
        user ""
        pass "passwordofuser1"
        is user1
  user ""
        pass "passwordofuser2"
        is user2

save and exit
Step-VIII[root@satishmalanch]# chmod 600 .fetchmailrc
Now Schedule fetchmail to run every minute with a cron job
Step-IX[root@satishmalanch]# crontab -e

0-59 * * * * fetchmail -v -f '/home/mail_admin/.fetchmailrc' &>/home/mail_admin/incoming.log
Save and exit

From above job fetchmail will reterive mails and will send output to incoming.log file

Now you have configured postfix server.Just restart all the required services with commands
[root@satishmalanch]# /etc/init.d/postfix/restart
[root@satishmalanch]# /etc/init.d/dovecot restart
Step-X To access mail from webmail you can enter url http;//yourserverip/webmail

You can configure setting with outlook or any other client.

To check downloading mails:
[root@satishmalanch]# tailf /home/mail_admin/incoming.log

No comments:

Post a Comment