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.
