Setting up Vpopmail with MySQL support, for Qmail
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/mysq
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 kamran@wbitt.com: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=kamran@wbitt.com,uid=711,required_score=5.0,rhost=localhost.localdomain,raddr=127.0.0.1,rport=54894,mid=51830.203.82.59.56.1210345345.squirrel@72.51.42.23,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.