Cyrus IMAP configuration

imapd.conf

The imapd.conf file should reside in /etc/. It is a rather simple file. The following is a standard imapd.conf where the imap user files and mailboxes are under /var/. The admins entry is the real important one. You must have a corresponding user in the LDAP database for the admins. The admins entry may contain a space separated list of users, who all have entries and passwords in the LDAP database.

Example 4-8. The imad.conf

    configdirectory: /var/imap
    partition-default: /var/spool/imap
    admins: <First User>
    sasl_pwcheck_method: PAM

The admins entry makes reference to a user that will be setup in the Open LDAP initial entries section of this document. You will need to replace <First User> with the actual name of a user in your LDAP database. This user or these users will have permission to create, delete and modify mail boxes and accounts within cyrus.

There are many other options for the ldap.conf file, If you compiled your own pam_ldap and are interested, please download the nss_ldap libraries from http://www.padl.com and examine the ldap.conf contained in the archive. There are also some other options explained in the ldap.conf file included with the RPM.

imap directories under /var

Note: if you used RPMs, most of this should be done for you, in fact the mkimap utility listed below is not included in the RPM.

First create an imap directory under /var and /var/spool. To do this execute the following commands:

Example 4-9. Creating Required Directories

    cd /var

    mkdir imap

    chown cyrus imap

    chgrp mail imap

    chmod 750 imap

    cd /var/spool

    mkdir imap

    chown cyrus imap

    chgrp mail imap

    chmod 750 imap

Change directories to the tools directory under the cyrus-imap source directory. There should be an executable named mkimap. su to the cyrus user, su cyrus, and type ./mkimap. Change directories to /var/imap. You will need to set the sync flag on several files and directories. This is done by typing the following commands:

Example 4-10. Setting the Sync Flag


    cd /var/imap

    chattr +S . user quota user/* quota/*

    chattr +S /var/spool/imap /var/spool/mqueue

setting up logging for cyrus

If you want to generate a log file for the imap server add the following line to /etc/syslog.conf and restart the syslog daemon by typing /etc/rc.d/init.d/syslog restart.

Example 4-11. Log Settings

    local6.debug /var/log/imapd.log

Create the log file for imapd by typing touch /var/log/imapd.log. Next add the daemon user to the mail group in the file /etc/group.

cyradm: adding mail users

The cyradm utility is used to manage mailboxes on the cyrus server. This utility is scriptable in Tcl. If you are familiar with Tcl you may want to write a script to add many users at once. There are also some examples in the doc directory of the cyrus-imap archive. To simply add a user with the command line, you must first log into the cyrus server as an admin defined in the imapd.conf file. Type the following:

Example 4-12. Add a User

    cyradm -u <First User> localhost

You will be prompted for a password, make sure that the LDAP server is up and running and that the user has an entry with a password. Enter the password and you should be given a prompt: >. At the prompt you can type help for a list of commands. To create a mailbox type the following:

Example 4-13. Create a Mailbox

    >cm user.<uid>

<uid> should be replace with the uid entry for the user you are creating the mailbox for. For example, if you are creating a mailbox for the <First User> account and the email address will be fuser@mydomain.com, then the uid field in the LDAP database should be fuser. The command you should type at the cyradm prompt would be >cm user.fuser. If you then do an >lm you should see user.fuser listed. For more information on the cyradm utility, please see the man page. There are more options, including the creation of public folders and ACLs that may be used in conjunction with IMAP4 accounts. If you intend to use POP3 accounts please read the next section.

POP3 accounts

If your users will be using POP3, you must create mailboxes, as described above. After doing so, you must create a directory under /var/imap/log with the users uid. For example, if <First User> (uid: fuser) wants POP3 access, then we would do the following:

Example 4-14. Creating mailboxes

    cd /var/imap/log

    mkdir fuser

    chown cyrus fuser

    chgrp mail fuser

    chmod 700 fuser

As long as the LDAP server is running, and the cyrus imap server and pam_ldap are configured properly, <First User> should be able to log on using an IMAP or POP3 client and check their mail.