Building an Advanced Mail Server
Pages: 1, 2
The wonderful folks over at Inter7 developed
vpopmail to handle the management of virtual domains using Qmail. Unfortunately
vpopmail is limited to a measly 23 million virtual hosts,
of which each are limited to only 23 million users. So if you have
more than 529 trillion users you may need to look elsewhere.
vpopmail User and Group
As noted in
INSTALL file, "[the]
FreeBSD folks have reserved 89 for the group and 89 for the user for
vpopmail." You will probably want to ensure
is running as uid and gid 89.
bash$ groupadd -g 89 vchkpw bash$ useradd -g vchkpw -u 89 -d /path/to/where/you/want vpopmail
you can put it wherever you wish. Just remember that all email messages will be
/var/lib/vpopmail, so choose a partition with plenty of
Setting up MySQL Support
The first thing you need to do is set up
vpopmail for MySQL.
This is done by doing some light code editing in a header file. Fire up your
favorite editor. Open up the file
vmysql.h and change the
following lines to match the configuration you set up in the MySQL section of
#define MYSQL_UPDATE_SERVER "localhost" #define MYSQL_UPDATE_USER "vpopmail" #define MYSQL_UPDATE_PASSWD "password" #define MYSQL_READ_SERVER "localhost" #define MYSQL_READ_USER "vpopmail" #define MYSQL_READ_PASSWD "password"
After you have finished editing
vmysql.h, compile the program.
Be sure to run
./configure --help before configuring the software.
Below is what I used to enable MySQL support and install
bash$ ./configure \ --enable-mysql=y --enable-auth-logging=n --enable-mysql-logging=n --enable-logging=e --enable-valias=y --enable-passwd=n --enable-defaultquota=15728640 --enable-roaming-users=y
There are a few things to note in the above configuration that you may want to change to suit your needs.
--enable-auth-loggingbecause SquirrelMail logs in and out every time a page is loaded, which can make logs grow quickly on active mail servers.
--enable-loggingenables logging only of errors.
--enable-defaultquotaThe default quota can be computed by using the equation (MB * 1024 * 1024) where MB is the number of megabytes you would like your default quota to be.
You may need to specify the location of your MySQL include and library directories with
--enable-passwd=n, only virtual users will have access to our mail server.
NFS users may wish to look at the
--enable-file-syncoptions. Because Qmail uses the alternative Maildir format to store messages, it works quite nicely with NFS.
After running the configure script, compile and install
vpopmail with the following commands:
bash$ make bash$ make install-strip
Note: Debian has packages for
vpopmail, however I could not
get them working properly with MySQL.
Adding domains is extremely simple. Before you create a domain you will want
to read the man pages for
vadddomain. There are options for mail
delivery, quotas, etc.
bash$ /path/to/vpopmail/bin/vadddomain example.com password
password is the password for email@example.com, who will
be the administrator for that domain. After you have created the domain your
domain's user directories and
.qmail files will exist in
You can use either
qmailadmin to create users or
bash$ /path/to/vpopmail/bin/vadduser firstname.lastname@example.org password
Courier IMAP is another piece of software by Inter7. It's a simple IMAP
server that was created specifically to work with Maildir. Read over the
INSTALL file before we get started to familiarize yourself with
the installation process.
bash$ ./configure \ --prefix=/usr/local/courier-imap \ --with-ssl \ --with-authvchkpw bash$ make bash$ make install bash$ make install-configure
--with-ssl is optional
Once you are done installing Courier IMAP, you need to edit a few
configuration options in its configuration file. Open
/usr/local/courier-imap/etc/imapd in your favorite editor and
change the following options.
editor's note: some of these options could use further explanation
100. (Many users will be using the web interface, which all come from a single IP.)
"-nodnslookup -noidentlookup -user=vpopmail -group=vchkpw".
IMAP_EMPTYTRASH=Trash:7,Sent:30to whatever you want. This option tells Courier to clear out these folders every 7 and 30 days, respectively. You can add extra folders there as well that you wish to have the server empty periodically.
After you have all of this up and running, you should be ready to fire up
your IMAP server. To start Courier IMAP at boot, copy
/usr/local/src/courier-imap-1.7.x/courier-imap.sysvinit to the
directory appropriate for your distro (many use
bash$ cp /usr/local/src/courier-imap-1.7.x/courier-imap.sysvinit \ /etc/init.d/courier-imap bash$ chmod 744 /etc/init.d/courier-imap bash$ /etc/init.d/courier-imap start
qmailadmin is a CGI interface to
vpopmail. It is totally optional, but will make administering your virtual domains, users, forwards, etc. much easier. Not only does it allow your postmaster to create and manage accounts, forwards, and aliases, but it allows users to log in and change passwords, set vacation messages, etc.
qmailadmin requires EZMLM, DJB's mailing list manager, which you may not wish to install. You can skip this step.
autoresponder is a prerequisite of
qmailadmin and does basic auto responding. After you have extracted the source, change into the package's directory.
bash$ make bash$ make man bash$ make setup
EZMLM is DJB's mailing list software which works great with Qmail. EZMLM's main website has been down for quite some time. I suggest you grab the source from DJB's EZMLM page. You will most likely wish to patch EZMLM with the famous IDX patch which adds a plethora of options. I found a working mirror where you can download ezmlm-idx-0.40.tar.gz. After you have extracted both the EZMLM source and the IDX patch, install EZMLM.
bash$ mv ezmlm-idx-0.xx/* ezmlm-0.53/ bash$ cd ezmlm-0.53 bash$ patch < idx.patch bash$ make mysql bash$ make clean bash$ make && make man bash$ make setup
bash$ ./configure \ --enable-cgibindir=/path/to/your/cgi-bin --with-htmllibdir=/path/to/your/html/docroot --enable-imagedir=/path/to/your/images/directory
There are several options to look into if you plan to allow clients to
administer their own domains.
--enable-maxmailinglists are just two of the options you may wish
to use. Be sure to check out
./configure --help for a complete
list of options.
bash$ make bash$ make install-strip
After you have installed
qmailadmin, you should be able to log
in to to
http://example.com/cgi-bin/qmailadmin to administer your
Now that you have everything installed and have created your users, you
should be able to log in. Because
vpopmail uses virtual hosts your
username will be
email@example.com, which is important to
remember. Because of Qmail's flexibility and the power of
vpopmail's MySQL support you can easily create domains and hand
over the ability to manage accounts to your customers, which leaves plenty of
Now that your mail server is running the hard part is over, but it is not yet complete. The second part of our series will cover installing Apache+PHP and Squirrel Mail. We will also customize Squirrel Mail with a few plugins that will make managing your web mail system a lot easier. In the third and final part of our series, you will see how easy it is to integrate both virus and spam protection into your new mail server.
Joe Stump is the Lead Architect for Digg where he spends his time partitioning data, creating internal services, and ensuring the code frameworks are in working order.
Return to the Linux DevCenter.
2005-07-16 13:57:44 crashoverride? [View]
Problem with vpopmail make
2005-03-25 05:06:34 peecee [View]
courier-imap compiling error
2004-09-09 13:00:45 Manis [View]
2004-09-01 07:32:57 centyx [View]
2004-07-18 03:54:49 Osiris [View]
Make in vpopmail
2004-06-24 03:02:48 Osiris [View]
Help required for configuring email server
2004-01-22 01:25:38 pareshrshah [View]
unable to read /etc/tcp.pop3.cdb
2003-11-18 07:25:15 anonymous2 [View]
pop3d not working
2003-11-17 01:45:41 kzahradnik [View]
I have this problem loggin in, using outlook express
2003-10-27 19:34:08 anonymous2 [View]
the make for vpopmail
2003-10-23 00:31:51 anonymous2 [View]
pop3 and smtp
2003-10-09 11:06:46 anonymous2 [View]
Second and third part ??
2003-10-08 05:30:54 anonymous2 [View]
I don't understand why you publish this???
2003-10-08 02:56:24 anonymous2 [View]
2003-10-03 09:26:33 anonymous2 [View]
I prefer dovecot to Courier IMAP
2003-10-01 20:27:28 anonymous2 [View]
Red Hat and ALL RPM-based distros
2003-10-01 00:17:00 datavortex [View]
2003-09-29 23:49:07 drunelson [View]
Redhat 9.0 will need important patches
2003-09-29 23:49:04 drunelson [View]