Vpopmail
What is vpopmail?
vpopmail is a virtual mail backend system. It is designed to work in conjunction with qmail's virtual domain implementation. vpopmail supports various backends to store user and domain configuration such as MySQL, PostgreSQL, LDAP and others.
Why vpopmail?
vpopmail provides a good set of management tools and a reasonably well designed structure which saves you implementing your own. vpopmail has also been around for a long time and enjoys support from a lot of other software packages related to mail which makes integration fairly simple.
What is this howto all about?
This howto will provide instructions on how to install vpopmail with MySQL database support and integrate it with various pieces of software related to email including certain packages that come with CentOS 4.
1. Installation requirements
An installed instance of qmail since vpopmail is tied to qmail. The mysql-devel package must be installed too in order to compile vpopmail with MySQL support.
If you do not have a qmail instance installed, then you can follow the following instructions to get one. However, this how to does not deal with qmail. Please see the qmail-toaster website (http://www.qmailtoaster.com/) for a qmail + vpopmail setup.
Download the qmail source tarball at http://cr.yp.to/software/qmail-1.03.tar.gz
Extract the source code.
Preparation for compiling involves adding two groups and 7 user accounts used by qmail.
mkdir /var/qmail groupadd nofiles useradd -s /sbin/nologin -g nofiles -d /var/qmail/alias alias useradd -s /sbin/nologin -g nofiles -d /var/qmail qmaild useradd -s /sbin/nologin -g nofiles -d /var/qmail qmaill useradd -s /sbin/nologin -g nofiles -d /var/qmail qmailp groupadd qmail useradd -s /sbin/nologin -g qmail -d /var/qmail qmailq useradd -s /sbin/nologin -g qmail -d /var/qmail qmailr useradd -s /sbin/nologin -g qmail -d /var/qmail qmails
Change directory into the qmail source code directory. (cd qmail-1.0.3)
Put 'gcc -O2 -include /usr/include/errno.h' into the conf-cc file.
Run 'make setup check' to compile qmail and install a qmail instance
Run './config-fast localhost' to do the very minimum configuration of qmail needed for vpopmail.
You now have a qmail instance that will satisfy vpopmail's requirements.
2. Building vpopmail with mysql support
Download the vpopmail source from sourceforge. This howto deals with version 5.4.17. http://sourceforge.net/project/showfiles.php?group_id=85937.
vpopmail normally uses uid 89 and gid 89 but since Postfix uses both, we need to use others. uid 91 and gid 91.
groupadd -g 91 vchkpw useradd -g vchkpw -u 91 vpopmail
Extract the source code from the tarball and change directory into the source code directory.
./configure --enable-mysql-replication --enable-sql-logging --enable-auth-module=mysql --disable-users-big-dir --enable-valias
This will give us the option to use a master MySQL server where writes for logging, user/domain creation are sent and mysql slaves that are used only for reading user/domain information by vpopmail and other software through its library. --enable-valias tells vpopmail to store email aliases in a MySQL database rather than .qmail files which we will not be using. All email addresses will be stored in one single table in this setup and aliases in a separate table.
make
3. Installing and configuring vpopmail for MySQL
make install/make install-strip
MySQL settings for vpopmail are stored in the file /home/vpopmail/etc/vpopmail.mysql. An example can be found below for a single MySQL database instance.
# MYSQL CONNECTION SETTINGS FOR VPOPMAIL # # Line 1 defines the connection to use for database reads, # Line 2 defines the connection to use for database updates/writes. # # If you omit line 2, then the same settings will be # used for both read and write. # # settings for each line: # host|port|user|password|database # localhost|0|vpopmail|vpopmailpass|vpopmail # # Note: # The value of host may be either a hostname or an IP address. # If host is 'localhost', then sockets (Unix) or named pipes (Windows) # will be used instead of TCP/IP to connect to the server.
vpopmail binaries are installed in /home/vpopmail/bin. They should be run with root when adding or deleting users/domains since they will change files under /var/qmail/control. You need to create the vpopmail database and grant access to it before using vpopmail.
Installation of vpopmail is now complete.
4. Glue for software that do not support vpopmail directly
courier software and vpopmail have a long history together. The courier authentication library is supported by a lot of mail related software that do not directly support vpopmail. It can thus provide the glue between vpopmail and these software such as maildrop. You can download courier-authlib and maildrop from http://sourceforge.net/project/showfiles.php?group_id=5404
4.1. courier-authlib
courier software will not compile under the root account. Also, to get courier-authlib to pick vpopmail libraries, you need to be able to access them during the configuration of the build process. It is suggested therefore that you use the vpopmail user for the build process of courier-authlib. The courier-authlib source needs a small patch to make it fully use vpopmail: courier-authlib-vpopmail.patch.
patch -p1 < courier-authlib-vpopmail.patch cd courier-authlib-0.58 ./configure --prefix=/usr/lib/courier --with-redhat \ --with-mailuser=vpopmail --with-mailgroup=vchkpw \ --with-mysql-libs=/usr/lib/mysql \ --with-mysql-includes=/usr/include/mysql make make install make install-configure
You can use this sample authdaemond sysvinit script that supports chkconfig to enable the service: authdaemond