Virtual Exim |
Index |
Feature List |
FAQ |
Integrating POP3 and IMAP |
Download Page
README |
Credits |
Wiki
POP3? IMAP? What are these things and why do I need them?
POP3 and IMAP servers allow your users to collect their mail, once it
arrives on your mail server. Typically, POP3 clients download the mail and
store it on their computers, while IMAP clients leave their messages on
the server. You must decide which is right for you.
Which POP3 and IMAP daemons are supported?
Currently the use of Courier IMAP for IMAP and/or POP3 transports is
supported, as is Qpopper with the MySQL patch for POP3 transport only.
These are the applications we have tested, which support lookups in MySQL
databases to retrieve client data. Cyrus is also mentioned here, but we
have not tested this. Instructions for configuring it are provided and if
anyone is able to test them out, we would appreciate it very much.
The Courier IMAP package by default provides both IMAP and POP3 demons.
You have two options for installing Courier-IMAP. First most modern Unix
operating systems support package management systems which can install
applications for you in a painless manner. Second, you can compile the
software source code yourself. I prefer the first method and it frequently
allows you to upgrade your software when new versions come out with the
most ease.
Here I will talk about how to install the software in ways I've tried, or
using instructions that have been passed to me by others. If you would
like to contribute installation instructions, please email them to us:
[email protected]
Installing Courier-IMAP 2.x on FreeBSD:
* We are going to be performing configuration for both IMAP and POP3
below. If you'd like to not run one of these two daemons, you can
simply ignore the steps for its configuration file.
cd /usr/ports/mail/courier-imap && make -DWITH_MYSQL install clean
cd /usr/local/etc/courier-imap/
cp imapd.dist imapd
vi imapd
Now, replace the following lines:
> Replace: AUTHMODULES="authdaemon"
> with: AUTHMODULES="authmysql"
AND:
> Replace: AUTHMODULES_ORIG="authdaemon"
> with: AUTHMODULES_ORIG=""
Make the same changes to the pop3d.dist file, after copying it to
pop3d.
Now create a file in that directory called authmysqlrc, with the
following contents:
MYSQL_SERVER localhost
MYSQL_USERNAME vexim
MYSQL_PASSWORD change
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE vexim
MYSQL_USER_TABLE users
MYSQL_CRYPT_PWFIELD crypt
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD username
MYSQL_HOME_FIELD pop
MYSQL_NAME_FIELD realname
Finally, perform these steps to move the startup scripts into
place, and start the daemons:
cd /usr/local/etc/rc.d
mv imapd.sh.dist imapd.sh
mv pop3d.sh.dist pop3d.sh
/usr/local/etc/rc.d/imapd.sh start
/usr/local/etc/rc.d/pop3d.sh start
These instructions were developed by Rossz Wentworth. He uses Qpopper for mail collection by remote clients, and assures us it works very well!
Get the Qpopper source from: http://www.eudora.com/qpopper/ Get the Mysql patch from: http://asteroid-b612.org/software/#qpopper Follow the instructions in the patch on how to apply it. Build Qpopper. Here's the command line I used to configure mine before building. Adjust the paths to match your system. === Sample settings for ./configure === ./configure \ --with-popperconfig=/etc/qpopper.config \ --enable-mysql \ --with-mysqlconfig=/etc/mysql-popper.conf \ --with-mysqllibpath=/usr/local/mysql/lib/mysql \ --enable-shy \ --enable-servermode \ --with-openssl \ --enable-maildrop-type=maildir ======================================= Leave out "--with-openssl" if you won't be supporting secure connections. This build is for use via inetd. If you would prefer a standalone daemon, include the switch "--enable-standalone". Use the sample mysql-popper.conf file but change the login name and password used to access the mysql database.
While recommending Virtual Exim to a user, the request for Cyrus support was raised. It was found the using Cyrus with MySQL was surprisingly easy, so this was created. Unfortunately as none of the development team currently run Cyrus, we can only hope that these instructions work, or aren't too far from what is required. If you are a Cyrus user, please let us know!
Installing Cyrus IMAP server:
Requirements and Prerequisites:
Mysql 3.23.xx or 4.xx (http://www.mysql.com/)
pam-mysql (http://sourceforge.net/projects/pam-mysql/)
Cyrus, or Cyrus-imapd (http://asg.web.cmu.edu/cyrus/)
Cyrus IMAP has the ability to authenticate users through PAM. This is
advantageous to those using the Virtual Exim system, as it allows them
to choose from another good IMAP server.
After all of the prerequisites above has been installed, and MySQL has
been configured according to the Virtual Exim documentation, continue
with the following steps:
========================================================================
Configuring your authentication system (/etc/pam.d):
If your system has /etc/pam.d as a directory, follow this section.
Several Linux distributions use this method.
Otherwise, skip to the next section.
* As root, edit the file /etc/pam.d/imap, and add the following
two lines:
auth sufficient pam_mysql.so user=vexim passwd=CHANGE host=localhost db=vexim table=users usercolumn=username passwdcolumn=crypt crypt=1
account required pam_mysql.so user=vexim passwd=CHANGE host=localhost db=vexim table=users usercolumn=username passwdcolumn=crypt crypt=1
Replace the word 'CHANGE' with the password exim uses to access the
MySQL database.
* If you plan to use Cyrus's POP, Sieve and SMTP services, copy
/etc/pam.d/imap, to:
/etc/pam.d/pop
/etc/pam.d/sieve
/etc/pam.d/smtp
========================================================================
Configuring your authentication system (/etc/pam.conf):
The BSDs (Net, Open and FreeBSD) as well as Solaris 8 use this method
for configuring PAM>
* As root, edit the file /etc/pam.conf, and change the 'imap' lines to
match this:
imap auth sufficient pam_mysql.so user=vexim passwd=CHANGE host=localhost db=vexim table=users usercolumn=username passwdcolumn=crypt crypt=1
imap account required pam_mysql.so user=vexim passwd=CHANGE host=localhost db=vexim table=users usercolumn=username passwdcolumn=crypt crypt=1
Replace the word 'CHANGE' with the password exim uses to access the
MySQL database.
* If you plan to use Cyrus's POP, Sieve and SMTP services, copy the
above lines, and replace 'imap' with 'pop', 'sieve' or 'smtp' in the
appropriate sections of the pam.conf file. Make sure you don't have
extra 'imap', 'pop' or 'smtp' lines floating in the file, which may
have been added when your operating system was installed.
========================================================================
Configuring Cyrus:
Finally, we need to configure Cyrus, to run with the appropriate
settings:
* Create the file /etc/imapd.conf (Linux) or
* /usr/local/etc/cyrus/imapd.conf (FreeBSD), and set the following
* variables:
postmaster: postmaster
configdirectory: /var/imap
partition-default: /var/spool/imap
admins: cyrus
allowanonymouslogin: no
allowplaintext: yes
sasl_mech_list: PLAIN
servername: YOUR.SERVER.HOSTNAME
autocreatequota: 10000
reject8bit: no
quotawarn: 90
timeout: 30
poptimeout: 10
dracinterval: 0
drachost: localhost
sasl_pwcheck_method: saslauthd
sievedir: /usr/sieve
sendmail: /usr/local/sbin/exim
sieve_maxscriptsize: 32
sieve_maxscripts: 5
#unixhierarchysep: yes
* Be sure to replace 'YOUR.SERVER.HOSTNAME' with the fully qualified
* domain name of your server.
* Now edit /etc/cyrus.conf (Linux) or
* /usr/local/etc/cyrus/cyrus.conf (FreeBSD), and set the following
* configuration parameters:
START {
# do not delete this entry!
recover cmd="ctl_cyrusdb -r"
}
SERVICES {
# add or remove based on preferences
imap cmd="imapd" listen="imap" prefork=0
pop3 cmd="pop3d" listen="pop3" prefork=0
sieve cmd="timsieved" listen="sieve" prefork=0
# at least one LMTP is required for delivery
# UNIX sockets start with a slash and are put into /var/imap/socket
lmtpunix cmd="lmtpd" listen="/var/imap/socket/lmtp" prefork=0
}
EVENTS {
# this is required
checkpoint cmd="ctl_cyrusdb -c" period=30
# this is only necessary if using duplicate delivery suppression
delprune cmd="ctl_deliver -E 3" period=1440
}
* Finally, we need to create some directories the Cyrus requires in
* order to run:
mkdir /var/imap
mkdir /var/spool/imap
mkdir /usr/sieve
chown cyrus:mail /var/imap
chown cyrus:mail /var/spool/imap
chown cyrus:mail /usr/sieve
chmod 750 /var/imap
chmod 750 /var/spool/imap
chmod 750 /usr/sieve
su - cyrus
/usr/local/cyrus-imapd/tools/mkimap
* The location of the above mkimap command, which create the remainder
* of the directories for Cyrus to run, may vary depending on your
* operating system or version of Cyrus. Please dig around.
* I've deliberately chosen not to tackle the SASL installation here,
* as a lot of people don't want or have no need for it. If you do wish
* to use it, there should be no problem with this setup. Just follow
* the instructions for installing Cyrus SASL.
These instructions were developed by Odhiambo Washington. He uses tpop3d to allow his users to POP their mail, at a large vexim installation.
Installing tpop3d 1.5.x on FreeBSD and intergrating with vexim2. TPOP3D is a very advanced POP3 server written by Chris Lightfoot and is homed at http://www.ex-parrot.com/~chris/tpop3d. The intention of tpop3d developers has been to write a server which is fast, extensible, and secure. tpop3d supports traditional (BSD-format) mailspools and Maildir. It also supports MySQL, perl, and external authentication methods. Recently tpop3d has been extended to support SSL, besides bulletins. NB: The configuration below is used on a production box which has over 20,000 pop accounts and runs pretty well. You can tune it to match your requirements. -Odhiambo Washington [[email protected]], 20031107. This HOWTO describes the steps you will take to install tpop3d on FreeBSD (4.x/5.x) and intergrate it with vexim2. cd /usr/ports/mail/tpop3d && make install clean cd /usr/local/etc cp tpop3d.conf.dist tpop3d.conf vi tpop3d.conf Apart from the other specifications, your tpop3d.conf should contain:: listen-address: a.b.c.d:110(server.name.tld) max-children: 30 log-bad-passwords: true append-domain: true timeout-seconds: 600 log-stderr: false no-detach: false mailbox: maildir:$mailstore/$(domain)/$(user)/Maildir auth-pam-enable: yes auth-pam-mail-group: $gid from variables.php auth-mysql-enable: true auth-mysql-mail-group: $gid from variables.php auth-mysql-hostname: HOSTNAME_OF_SQL_SERVER auth-mysql-database: vexim_db_name auth-mysql-username: vexim_db_username auth-mysql-password: vexim_db_password auth-mysql-pass-query: SELECT CONCAT(pop,'/Maildir'),CONCAT('{crypt}', users.crypt),\ users.uid,'maildir' FROM users WHERE username='$(local_part)@$(domain)' Finally, perform these steps to move the startup scripts into place, and start the daemons: cd /usr/local/etc/rc.d mv tpop3d.sh.dist tpop3d.sh /usr/local/etc/rc.d/tpop3d.sh start Of course your MySQL server should be running already. Enjoy!!