4. Configuration

4.1. Configuring MySQL

4.2. Configuring PAM

Now we need to get sure that PAM knows how to authenticate the Cyrus users

You have to create the file /etc/pam.d/imap with the following entries:

auth sufficient pam_mysql.so user=mail passwd=secret host=localhost db=mailadmin table=accountuser usercolumn=username   passwdcolumn=password crypt=0

auth sufficient pam_unix_auth.so

account required pam_mysql.so user=mail passwd=secret host=localhost db=mail table=accountuser usercolumn=username passwdcolumn=password   crypt=0

account  sufficient       pam_unix_acct.so

The lines containing pam_unix_auth.so and pam_unix_acct.so are only needed if you are migrating from wu-IMAP to cyrus. This way the users can be authenticate with its old unix-password and its new mysql-based password

If you will use Cyrus also for POP-Service just cp /etc/pam.d/imap /etc/pam.d/pop

4.3. Configuring Postfix

Postfix needs two major config files: main.cf and master.cf. Both needs now our attention.

4.3.1. master.cf

You need to change just one line:

old:

argv=/cyrus/bin/deliver 

new:

argv=/usr/cyrus/bin/deliver

4.3.2. main.cf

Here you need to change some more things like hostname, relaying, alias-lookups etc.

First change hostname:

myhostname = foo.bar.org

mydestination

Here you have to put all domainnames that are local (corresponding to sendmail's /etc/mail/sendmail.cw) If you have multiple domains separate them with comma

mydestination = foo.bar.org, example.com, furchbar-grausam.ch, whatever.domain.tld

relayhost

Here you define where to deliver outgoing mails. If you do not provide any host. mails are delivered directly to the destination smtp host. Usually your relayhosts are your providers smtp-server

relayhost = relay01.foobar.net relay02.foobar.net relay03.foobar.net

mailtransport

Here you define how the mails accepted for local delivery should be handled. In our situation mails should be delivered by the cyrus delivery-program

mailbox_transport = cyrus

At the end of file you need to add:

virtual_maps = hash:/etc/postfix/virtual, mysql:/etc/postfix/mysql-virtual.cf

Outgoing addresses should be rewritten from i.e test0002@domain to user.name@virtualhost.com. This is important if you like to use a webmail interface.

sender_canonical_maps = mysql:/etc/postfix/mysql-canonical.cf 

Now you need to create the file /etc/postfix/mysql-virtual.cf:

#
# mysql config file for alias lookups on postfix
# comments are ok.
#

# the user name and password to log into the mysql server
hosts = localhost
user = mail
password = secret

# the database name on the servers
dbname = mailadmin

# the table name
table = virtual

#
select_field = dest
where_field = alias
additional_conditions = and status = '1'

And the file /etc/postfix/mysql-canonical.cf:

# mysql config file for canonical lookups on postfix
# comments are ok.
#

# the user name and password to log into the mysql server
hosts = localhost
user = mail
password = secret

# the database name on the servers
dbname = mail

# the table name
table = virtual
#
select_field = alias
where_field = username
# Return the first match only
additional_conditions = and status = '1' limit 1

4.4. Configuring Cyrus IMAP

There is only little changes needed. Edit /etc/imapd.conf and take care that the following entry is done

    sasl_pwcheck_method: pam

This tells the Cyrus IMAP to authenticate using PAM

If you want to enable Cyrus' TLS/SSL facilities you have to create a certificate first. This requires an OpenSSL installation

openssl req -new -nodes -out req.pem -keyout key.pem  
openssl rsa -in key.pem -out new.key.pem
openssl x509 -in req.pem -out ca-cert -req \
-signkey new.key.pem -days 999 

cp new.key.pem /var/imap/server.pem

echo tls_cert_file: /var/imap/server.pem >> /etc/imapd.conf
echo tls_key_file: /var/imap/server.pem >> /etc/imapd.conf

If you like to use sieve (A Mail Filtering Language), you must change an entry in /etc/services. Add or change the following line:

sieve           2000/tcp

4.5. Configuring Web-cyradm

You just need to do some changes in /usr/local/apache/htdocs/web-cyradm/config.inc.php
cp   config.inc.php-dist config.inc.php

Edit the file and change the password and databasename to the appropriate values