Vpopmail with MySQL support:
Note: vpopmail assumes that Qmail is installed in /var/qmail .
QMR provides vpopmail-5.4.13.tar.gz QMR package. Whereas latest is 5.4.27, on the Vpopmail download site:
http://sourceforge.net/project/showfiles.php?group_id=85937
Download this new version:
cd /downloads/qmailnew
wget http://internap.dl.sourceforge.net/sourceforge/vpopmail/vpopmail-5.4.27.tar.bz2
tar xjf vpopmail-5.4.27.tar.bz2
cd /downloads/qmailnew/vpopmail-5.4.27
Let's do the preparation first. We already have created a user vpopmail and group vchkpw earlier. If not, create them now:
groupadd -g 702 vchkpw
useradd -u 708 -g vchkpw -d /home/vpopmail -s /sbin/nologin -p '*' vpopmail
mkdir ~vpopmail/etc
chown vpopmail:vchkpw ~vpopmail/etc
echo "localhost|0|vpopmailuser|redhat|vpopmail" > ~vpopmail/etc/vpopmail.mysql
chown vpopmail.vchkpw ~vpopmail/etc/vpopmail.mysql
chmod 640 ~vpopmail/etc/vpopmail.mysql
The echo command above specifies the following pieces of information:-
Server, where DB is hosted: localhost
Mysql listening on port : 0 (If MySQL runs on localhost, on default 3306. Any non-standard port must be mentioned, instead of 0).
Name of database : vpopmail
Username for the database : vpopmailuser
Password for this DB user: redhat
Create vpopmail Database:
mysql -u root -p
CREATE DATABASE vpopmail;
GRANT all ON vpopmail.* TO vpopmailuser@localhost IDENTIFIED BY 'redhat';
flush privileges;
quit;
Make sure you connect successfully:
mysql -u vpopmailuser -D vpopmail -predhat
Configure and compile:
cd /downloads/qmailnew/vpopmail-5.4.27
Warning:
Don't use the configure / compile options mentioned in QMR Guide ,which are:
./configure --enable-logging=p --enable-auth-module=mysql \
--disable-passwd --enable-clear-passwd \
--disable-many-domains --enable-auth-logging --enable-sql-logging \
--enable-valias --disable-mysql-limits
Instead, use the following to compile Vpopmail :-
./configure --enable-logging=p \
--enable-auth-module=mysql --disable-clear-passwd \
--enable-many-domains \
--enable-sql-logging --enable-mysql-replication \
--disable-roaming-users \
--enable-libdir=/usr/lib64/mysql
Note: Use "--enable-libdir=/usr/lib64/mysql" only on 64 bit systems. Not needed on 32 bit systems. And if not provided on 64 bit system, you will get errors during make.
These options are explained in the doc files which come with the vpopmail package. Also on http://www.qmailwiki.org/Vpopmail#Getting_started
--enable-vpopuser=USER OS User name allocated to vpopmail vpopmail.
--enable-vpopgroup=GROUP Group name allocated to vpopmail vchkpw.
--enable-roaming-users Enable POP-before-SMTP functionality.
--disable-clear-passwd Don't store a cleartext version of the password in addition to the encrypted version.
--enable-spamassassin Enable spamassassin. See README.spamassassin for more info.
--enable-libdir=DIR Your MySQL/Oracle 'lib' directory.
--enable-auth-module=MOD Nominate how to store the vpopmail account information (cdb (default), mysql, pgsql, ldap, oracle, sybase, or activedir).
--enable-logging=OPT Log to syslog: n=nothing, e=errors only (default), y=all attempts, p=errors with passwords, v=verbose (all attempts, withpasswords).
--enable-log-name=TEXT Set syslog name vpopmail.
--disable-auth-logging Don't record time and ip of last auth attempt. Valid only for CDB, MySQL, PGSQL, LDAP, ActiveDir.
--enable-sql-logging Enable authentication logging to MySQL/Postgres.
--enable-mysql-limits Use MySQL to store limits instead of .qmailadmin-limits files.
--enable-mysql-replication Enable support for replicated MySQL auth servers.
--enable-valias Store email aliases in MySQL.
--disable-many-domains Creates a table for each virtual domain instead of storing all users in a single table. Only valid for MySQL and PostgreSQL.
--enable-many-domains Creates one large table for all virtual domains.Only valid for MySQL and PostgreSQL.
A note from the vpopmail author:
“I used to recommend the --disable-many-domains switch – which tells vpopmail to create one MySQL table per email domain. When I first started building vpopmail servers, I found this to be the most logical way, having each domain in its own table. However there has been some discussion about this config option on the vpopmail mailing lists, and it sound like this option may be removed at some point in the future. If you have a lot of domains on your server, having each domain in its own table can hurt performance. I now agree that --enable-many-domains is probably the better choice.”
Also note that SMTP-AUTH is preferred over “POP before SMTP” (a.k.a Roaming users). So we used disable-roaming-users.
Enabling the “--enable-spamassassin” also depends on your requirements. If I want to control anti-spam through SpamAssassin, server wide, “not” on individual user level, I would not use “--enable-spamassassin”.
So, coming back to the configuration and compilation steps again:
./configure --enable-logging=p --enable-auth-module=mysql \
--disable-clear-passwd \
--enable-many-domains \
--enable-sql-logging --enable-mysql-replication \
--disable-roaming-users \
--enable-libdir=/usr/lib64/mysql
...
...
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
vpopmail 5.4.27
Current settings
---------------------------------------
vpopmail directory = /home/vpopmail
domains directory = /home/vpopmail/domains
uid = 708
gid = 702
roaming users = OFF --enable-roaming-users
tcpserver file = /home/vpopmail/etc/tcp.smtp
open_smtp file = /home/vpopmail/etc/open-smtp
rebuild tcpserver file = ON --enable-rebuild-tcpserver-file (default)
password learning = OFF --disable-learn-passwords (default)
md5 passwords = ON --enable-md5-passwords (default)
file locking = ON --enable-file-locking (default)
vdelivermail fsync = OFF --disable-file-sync (default)
make seekable = ON --enable-make-seekable (default)
clear passwd = OFF --disable-clear-passwd
user dir hashing = ON --enable-users-big-dir (default)
address extensions = OFF --disable-qmail-ext (default)
ip alias = OFF --disable-ip-alias-domains (default)
onchange script = OFF --disable-onchange-script (default)
auth module = mysql --enable-auth-module=mysql
mysql replication = ON --enable-mysql-replication
sql logging = ON --enable-sql-logging
mysql limits = OFF --disable-mysql-limits
SQL valias table = OFF --disable-valias
auth inc = -I/usr/include/mysql
auth lib = -Xlinker -R -Xlinker /usr/lib/mysql -L/usr/lib/mysql -lmysqlclient -lz -lm
system passwords = OFF --disable-passwd (default)
pop syslog = show failed attempts with clear text password --enable-logging=p
auth logging = ON --enable-auth-logging (default)
Many domains per SQL table = --enable-many-domains
spamassassin = OFF --disable-spamassassin
maildrop = OFF --disable-maildrop (default)
[root@www vpopmail-5.4.27]#
Now compile it:
[root@www vpopmail-5.4.27]# make && make install-strip
...
...
/usr/bin/install -c -o vpopmail -m 711 -g vchkpw -s 'vpopmaild' '/home/vpopmail/bin/vpopmaild'
/usr/bin/install -c -o vpopmail -m 711 -g vchkpw -s 'vlist' '/home/vpopmail/bin/vlist'
/usr/bin/install -c -o vpopmail -m 711 -g vchkpw -s 'authvchkpw' '/home/vpopmail/bin/authvchkpw'
make[3]: Leaving directory `/downloads/qmailnew/vpopmail-5.4.27'
make[2]: Leaving directory `/downloads/qmailnew/vpopmail-5.4.27'
make[1]: Leaving directory `/downloads/qmailnew/vpopmail-5.4.27'
WARNING:
Do not use the “--enable-maildrop” switch in vpopmail, otherwise you will not get any mails, and will get the following "Unable to open mailbox" errors in the /var/log/maillog:
May 9 20:04:07 www spamd[31043]: spamd: clean message (-1.4/5.0) for This e-mail address is being protected from spambots. You need JavaScript enabled to view it :711 in 1.3 seconds, 934 bytes.
May 9 20:04:07 www spamd[31043]: spamd: result: . -1 - ALL_TRUSTED scantime=1.3,size=934,user= This e-mail address is being protected from spambots. You need JavaScript enabled to view it ,uid=711,required_score=5.0,rhost=localhost.localdomain,raddr=127.0.0.1,rport=54894,mid=< This e-mail address is being protected from spambots. You need JavaScript enabled to view it >,autolearn=unavailable,shortcircuit=no
May 9 20:04:07 www spamd[31040]: prefork: child states: II
May 9 20:04:07 www maildrop[19011]: Unable to open mailbox.