Installing of Postfix, Postfixadmin, Dovecot and Squirrelmail is not an easy task. There are some customization works you need to be done in order to get it works. I hope the following guide step by step instruction will be handy for you :)
My mail server system information:
hostname : example.centos.local
IP address: 192.168.139.128
Netmask : 255.255.255.0
Gateway : 192.168.139.2
There are 2 domains that I will setup for this guide. There are
domain name : abc.local
user mailbox : alex@abc.local
domain name : xyz.local
user mailbox : yasmin@xyz.local
The postfix admin login we will be using is post@example.local, where example.local will not be created in Postfixadmin's virtual domain. This is to show you that, the email system we setup later is solely running on Postfixadmin's virtual domain
Note:
- I am going to show you only setup a mail server that works within your local Lan. To sent a mail outside your organization, you must make sure you have a valid domain name, DNS and MX record is configure properly. You need to change the host file under /etc/hosts and check the /etc/nsswitch.conf to speed up the dns resolve.
- My system is current SELinux disabled. If you wish turn Postadmin on, please relocate your Postfixadmin into /usr/share
#cat /etc/hostsDo not remove the following line, or various programs# that require network functionality will fail. 127.0.0.1 centos.example.local centos localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6192.168.139.128 centos.example.local <-- Add in your server name and IP |
# cat /etc/nsswitch.conf | grep hosts
|
Step 0: Install prerequisite packages
If you cannot install the packages in one line, then try to install them one by one.
yum -y install system-switch-mail, dovecot, squirrelmail, mysql-server, php-imap |
Step1: Backup the current Sendmail configuration
CentOS Linux default MTA is Sendmail. Since we are swtching to new MTA-Postfix. It is advisable to backup current sendmail config and bin to new location before we proceed.
First, I will create new folder call backup. Next, I backup all the files and record the sendmail path to a text.
#mkdir /backup#touch /backup/sendmail.config.location.txt #which sendmail mailq newaliases > /backup/sendmail.config.location.txt #which sendmail mailq newaliases /usr/sbin/sendmail /usr/bin/mailq /usr/bin/newaliases #cp -var /usr/sbin/sendmail /backup #cp -var /usr/bin/mailq /backup #cp -var /usr/bin/newaliases /backup |
Step2 Add in CentosPlus repos for postfix
Postfix installation by CentOS default repo does not support mysql addon. We need to use the specified postfix that enable the mysql support. Also, we want to avoid any disruptive update on our customised postfix package, you need to add in exclude=postfix-* for base and updates repo.
#vim /etc/yum.repos.d/CentOS-Base.repo #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5[base] includepkgs=postfix-* [base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5exclude=postfix-* #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5exclude=postfix-* |
Step5: Install postfix from centosplus repo
The default package of posftfix does not work with Virtual Domains and Virtual Users. If you have installed it earlier, you must remove it. Use "rpm -e" or "yum remove" to remove it.
If you are not install postfix yet, the run the following command will only download and install te postfix from centosplus.
#yum install -y --enablerepo=centosplus postfix |
Step6: verify the postfix package installed
Now, let us check the packages information been installed. Good, that is the package that we need.
#rpm -qa postfixpostfix-2.3.3-2.1.centos.mysql_pgsql# rpm -qi postfixName : postfix Relocations: (not relocatable)Version : 2.3.3 Vendor: CentOS Release : 2.1.centos.mysql_pgsql Build Date: Tue 07 Oct 2008 08:29:16 PM MYT Install Date: Sat 20 Mar 2010 10:32:42 PM MYT Build Host: builder16.centos.org Group : System Environment/Daemons Source RPM: postfix-2.3.3-2.1.centos.mysql_pgsql.src.rpm Size : 8668814 License: IBM Public License Signature : DSA/SHA1, Tue 11 Nov 2008 09:32:36 AM MYT, Key ID a8a447dce8562897 URL : http://www.postfix.org Summary : Postfix Mail Transport Agent Description : Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL), TLS |
Step7: verify the postfix package support the mysql
Before proceeding with the Postfix configuration, make sure that the postfix version you have has MySQL support. run
postconf -m
and verify that mysql appears in the list. If mysql isn’t there, uninstall postfix using yum. Then, download the centosplus repository again, and install manually.#postconf -mbtreecidr environ hash ldap mysql <-- this means the postfix package support the mysql database nis pcre pgsql proxy regexp static unix |
Step8 : Install system-switch-mail, mysql, system-switch-mail,dovecot, squirrelmail
Now, let us download all the packages we need.
#yum -y install php-mysql php-imap, php-ldap, php-mbstring |
Step9: Switching default Sendmail to Postfix Linux mail system
The system-switch-mail tool is the Mail Transpot Agent Switcher that enable you to switch within various Mail Trainsport Agent that installed at your system. If your system is using Sendmail by default, we need switch to postfix.
#system-switch-mail |
Step10: verify the setting of our new MTA
Before we proceed further configuration, lets us verify on the default MTA setting. If everything is correct, you should see the highlighted text changed to sendmail.postfix
#alternatives --display mtamta - status is manual.link currently points to /usr/sbin/sendmail.postfix |
We also going to check if our mailq, sendmail and aliases has the correct configured with postfix
#ls -l /etc/alternatives/mta-*
lrwxrwxrwx 1 root root 40 Mar 13 14:08 /etc/alternatives/mta-aliasesman -> /usr/share/man/man5/aliases.postfix.5.gz |
Step10: Remove Sendmail packages
My previous post suggest that although both mail server packages (Sendmail and Postfix) are compatible with each other. I strongly suggest you remove Sendmail packages to only allow one mail system in the sever. Due to CentOS Linux needs minimum one mail server installed. You must make sure that you installed Postfix first then remove Sendmail! Else, you will faced with some libraries dependencies issues.
To remove Sendmail packages, please use rpm -e command
yum -y remove sendmail |