This guide will show you how to setup an email server accessible using a POP3, IMAP or web browser client. It will also show you how to include virus scanning and spam tagging in the mail server. If you have an existing Active Directory or LDAP infrastructure, the last section will show you how to integrate it into your email server so you won’t have to maintain two sets of user accounts.
How to install Linux
You can use either Red Hat Enterprise Linux 5 or CentOS 5. RHEL 5 can be purchased from Red Hat and comes with support. CentOS 5 on the other hand can be downloaded here.
To simplify our administration tasks, log in as the user root and specify your root password. This is not the recommended way of administering a Linux box, but for the tasks at hand it is the most efficient way.
How to install SMTP, POP3, IMAP and Webmail service
Postfix will be providing the SMTP service, Dovecot will provide the POP3 and IMAP service, while Apache and SquirrelMail will provide the Webmail service.
How to create mailboxes, aliases and distribution groups
How to add antivirus and antispam filtering
We will be using Clam AntiVirus for virus scanning, SpamAssassin for the spam tagging and MailScanner to integrate them into Postfix.
You can greatly reduce the volume of spam and viruses reaching your mail server if you are willing to give up something. If you are willing to have your mail delayed (time), install Postgrey. If you are willing to spend (money), get the Barracuda Spam Firewall.
Before deploying your new mail server, see Mail Server Checklist to ensure your new mail server will have a good sending reputation and can be trusted.
How to integrate Active Directory/LDAP
Integrating Active Directory/LDAP into your mail server will turn your Linux email server into a lean and mean Exchange like machine. And you won’t have to deal with Linux system accounts or edit configuration files for common tasks like creating mailboxes and mailing lists. And finally, you can provide your users with standard address book.

Using Winbind to integrate Active Directory user accounts.Another way to integrate Active Directory into your mail server. I highly recommend using the virtual user solution above instead of this one.
***
Posted on 4/16/2007 and last updated on 10/5/2008
Filed under CentOS 5 , Red Hat Enterprise Linux 5
ShareThis















August 28th, 2007 at 9:40 am
Galeng galeng naman ni koya
January 2nd, 2008 at 12:06 pm
Hi,
I have successfully integrated my Linux (Samba/Winbind) into Active Directory (2003).
But not able to mail or accessing mail using Active Directory accounts.
Postfix and Dovecot is working for local unix accounts only.
Whats the things I need to configure at my Postfix and Dovecot?
Pls help.
Mahmud
January 12th, 2008 at 1:16 am
Hi,
There’s no additional configurations necessary, it should work transparently. Check out
Using Winbind to integrate Active Directory user accounts, it shows a few tests to check if Postfix and Dovecot can use your Active Directory accounts.
March 4th, 2008 at 4:06 pm
Why you are usinng GUI who the fuck is using gui on a server its not a Desktop ?????
March 5th, 2008 at 8:58 am
One word - Productivity.
I’m not a Unix/Linux expert but thanks to Red Hat’s Server GUI tools, I can manage one like a pro. With Red Hat’s Server GUI tools, I was able to immediately get right down to the task of implementing a mail server. If not for the GUI, I’d be spending more time learning how to use vi; figuring out arcane Linux commands like chmod, chown, useradd, groupadd, etc; and dealing with configuration files for basic tasks like setting up a firewall than setting up the mail server.
I made the guides simple and easy to follow because I’m targeting people who have no Linux experience but would like deploy a powerful, reliable, and minimal to zero software cost mail server.
After I made the GUI guides above, I tried to make a guide for a traditional text based Linux mail server using Ubuntu Server. But after installing Ubuntu Server and stared at the empty screen, that’s when I appreciated even more Red Hat’s Enterprise Linux package.
March 13th, 2008 at 6:16 am
Any tips on Dovecot configuration.
March 13th, 2008 at 12:11 pm
Hmm… What kind of tips? I have a few for Postfix but not for Dovecot because I see Dovecot only as a service for POPing mail.
Do you have any specific problem with Dovecot? I was able to build up a few articles for Postfix because I had a few itches that needs scratching.
March 25th, 2008 at 4:22 am
hi to all
im about to finish my 1st time configuration of mail server… please help where im going to change the domain instead of filename@localhost.localdomain.. i want to set it as my own “localhost”.com to appear like lhan@upc.com
thnx
March 30th, 2008 at 3:13 am
You can set it by editing the /etc/sysconfig/network file in centos 5. You can also do it via the GUI.
March 30th, 2008 at 12:15 pm
Hi,
I want to get opinion on a distributed mail server system. One that you have two mail servers as primary and secondary, a separate mail delivery server, and a separate spam checker server. All in all, you have four separate servers to handle mail to your network. I’m admin for a school with around 10000+ users and I wanna implement a mail server solution with this architecture.
April 9th, 2008 at 2:06 pm
sir i want to install mail scanner in cent os 5 please send me all steps for install the mail scanner
April 9th, 2008 at 10:41 pm
Hi Gaurav,
Please see the section How to add antivirus and antispam filtering. You probably did not notice that steps 1, 2, and 3 are active links.
April 22nd, 2008 at 6:52 am
Hi
I see you have the guide for squirrelmail, do you have one for Horde, or even better the inclusion of Cpanel?
Thanx for the great effort
April 27th, 2008 at 8:23 am
This guide is good…
May 4th, 2008 at 8:04 am
hi,
Thanks for u r good material, if u have any possibilities publish how to configure samba server in centos5 at the time of installation.
May 22nd, 2008 at 9:52 am
great guide, exactly what i needed after spending three days trying to configure SUSE mail server in CLI mode.. with no result of course as no ‘pro’ yet. thanks for your work!
May 22nd, 2008 at 9:56 am
>>>>
Amir Says:
March 4th, 2008 at 4:06 pm
Why you are usinng GUI who the fuck is using gui on a server its not a Desktop ?????
>>>>
your language and comment is not welcome and uncalled for here. neither it is appropriate. with modern computers and disk space one can install GUI without thinking of overhead on the machine. plus it eases the management for some folks. i wonder how did ‘pro’ like you come across this article?
May 22nd, 2008 at 11:47 am
Hi Al,
Thanks, I’m glad you found this site helpful
May 29th, 2008 at 4:04 pm
Hi,
I find integrating smtp+pop+imap+virus/spamscanners amongst the most timeconsuming tasks around, but you just saved me dozens of hours. Thanks for this fantastic how-to!
July 17th, 2008 at 3:15 pm
After sucessfully installing the mail server using these excellent directions, escpecailly since I am a newbie, I received the following errors after the automatic upgrades (YUM) were run. Any help would be appreciated. How can I resolve this dependency hell??????
[root@mail ~]# yum -t update
Loading “fastestmirror” plugin
Loading mirror speeds from cached hostfile
* rpmforge: apt.sw.be
* base: mirror.rhsmith.umd.edu
* updates: mirror.trouble-free.net
* addons: mirrors.unbornmedia.com
* extras: mirror.linux.duke.edu
Setting up Update Process
Resolving Dependencies
–> Running transaction check
—> Package perl-File-Temp.noarch 0:0.20-1.el5.rf set to be updated
—> Package perl-bignum.noarch 0:0.23-1.el5.rf set to be updated
—> Package perl-IO.i386 0:1.2301-1.el5.rf set to be updated
—> Package perl-Math-BigRat.noarch 0:0.22-1.el5.rf set to be updated
—> Package perl-Math-BigInt.noarch 0:1.89-1.el5.rf set to be updated
–> Finished Dependency Resolution
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
perl-File-Temp noarch 0.20-1.el5.rf rpmforge 46 k
perl-IO i386 1.2301-1.el5.rf rpmforge 99 k
perl-Math-BigInt noarch 1.89-1.el5.rf rpmforge 174 k
perl-Math-BigRat noarch 0.22-1.el5.rf rpmforge 30 k
perl-bignum noarch 0.23-1.el5.rf rpmforge 40 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 5 Package(s)
Remove 0 Package(s)
Total download size: 389 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Check Error:
file /usr/share/man/man3/File::Temp.3pm.gz from install of perl-File-Temp-0.20-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/bigint.3pm.gz from install of perl-bignum-0.23-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/bignum.3pm.gz from install of perl-bignum-0.23-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/bigrat.3pm.gz from install of perl-bignum-0.23-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Dir.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::File.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Handle.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Pipe.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Poll.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Seekable.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Select.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Socket.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Socket::INET.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/IO::Socket::UNIX.3pm.gz from install of perl-IO-1.2301-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/Math::BigRat.3pm.gz from install of perl-Math-BigRat-0.22-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/Math::BigFloat.3pm.gz from install of perl-Math-BigInt-1.89-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/Math::BigInt.3pm.gz from install of perl-Math-BigInt-1.89-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/Math::BigInt::Calc.3pm.gz from install of perl-Math-BigInt-1.89-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
file /usr/share/man/man3/Math::BigInt::CalcEmu.3pm.gz from install of perl-Math-BigInt-1.89-1.el5.rf conflicts with file from package perl-5.8.8-10.el5_2.3
Error Summary
————-
[root@mail ~]#
September 16th, 2008 at 9:58 am
hi..
is this configuration for mail server tested??
can u send me pls a setup a mail server..
tnx
September 23rd, 2008 at 1:53 pm
Hi,
I installed & configured all you said. but when I try to mail from a user to another user, I can’t see that email in recipient user. can you help me what can I do & what is wrong to this mail server?
tnx
September 23rd, 2008 at 9:58 pm
Hi Parsa,
How did you send the mail, using a mail client or a telnet session? If you used a telnet session, that’s the expected result. If you used a mail client, make sure you didn’t use BCC to specify the recipients.
September 23rd, 2008 at 9:59 pm
Hi exits,
Yes, the configuration is tested to be working. Just follow the instructions on this page.
September 27th, 2008 at 6:27 pm
Hi consultant,
I corrected previous problem.
Thanks for your reply.
But I have another problem.
When I try to send an email from both squirrel and telnet to an external email address (eg.: myemailid@yahoo.com) it doesn’t send that email and in /var/log/maillog it says:
Sep 27 22:42:05 mailer postfix/smtp[29455]: connect to f.mx.mail.yahoo.com[209.191.88.247]: Connection refused (port 25)
Sep 27 22:42:05 mailer postfix/smtp[29455]: connect to f.mx.mail.yahoo.com[68.142.202.247]: Connection refused (port 25)
Sep 27 22:42:05 mailer postfix/smtp[29455]: connect to c.mx.mail.yahoo.com[216.39.53.3]: Connection refused (port 25)
Sep 27 22:42:05 mailer postfix/smtp[29455]: connect to e.mx.mail.yahoo.com[216.39.53.1]: Connection refused (port 25)
Sep 27 22:42:05 mailer postfix/smtp[29455]: connect to d.mx.mail.yahoo.com[66.196.82.7]: Connection refused (port 25)
Sep 27 22:42:05 mailer postfix/smtp[29455]: 50BBE11F036B: to=, relay=none, delay=289, delays=289/0.01/0.01/0, dsn=4.4.1, status=deferred (connect to d.mx.mail.yahoo.com[66.196.82.7]: Connection refused)
Help me about this issue, please!
September 29th, 2008 at 2:24 am
tnx for reply.. soon i will try this mail conf. to setup a mail server..
can i have ask something.. have u also know to setup a good setup of squid caching server..
tnx again…
October 5th, 2008 at 7:11 am
Hi Parsa,
I’ve just written Mail Server Checklist. Please check it out to ensure your mail server will have a good sending reputation and can be trusted.