CyrusIMAP

From Rivalug Wiki

Jump to: navigation, search

Contents

History of this document

originially developed here: http://rivalug.org/forums/index.php?topic=39.0 --Carlisle 14:26, 18 Aug 2004 (EDT)

=Goal= Using Fedora or Centos as a base, I would like to configure imap mail, spam assassin, and clam antivirus to create a fully functional mail system.

First I will work on IMAP. There are two imap mail server packages provided: dovecot and cyrus-imap. This document will only cover cyrus imap, which is considered the more difficult but more scalable solution.

References

1. Cyrus Howto - a bit out of date.
2. Fedora List post
3. configuring sendmail with cyrus
4. Managing IMAP

Also read:

Packages

here are the version numbers of the applications used in this example:

sendmail-cf-8.13.8-2.el5
sendmail-8.13.8-2.el5
cyrus-sasl-lib-2.1.22-4
cyrus-imapd-perl-2.3.7-1.1.el5
cyrus-sasl-plain-2.1.22-4
cyrus-sasl-2.1.22-4
cyrus-imapd-utils-2.3.7-1.1.el5
cyrus-imapd-2.3.7-1.1.el5

Proceedure

Using 2 as a guide I did steps 1-5 as follows:

Authentication

At this time we will use pam and authenticate against the /etc/shadow file. Authentication against openldap will be shown later.

Edit /etc/sysconfig/saslauthd

# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=pam
[root@myserver root]# service saslauthd restart
Stopping saslauthd:                                        [  OK  ]
Starting saslauthd:                                        [  OK  ]

daemons

Edit /etc/cyrus.conf

# UNIX sockets start with a slash and are put into /var/lib/imap/sockets
SERVICES {
  # add or remove based on preferences
##  imap        cmd="imapd" listen="imap" prefork=5
  imaps         cmd="imapd -s" listen="imaps" prefork=1
##  pop3        cmd="pop3d" listen="pop3" prefork=3
##  pop3s       cmd="pop3d -s" listen="pop3s" prefork=1
  sieve         cmd="timsieved" listen="sieve" prefork=0

This will only run imap via ssl

[root@myserver root]# vi /etc/imapd.conf
[root@myserver root]# service cyrus-imapd restart
Shutting down cyrus-imapd:                                 [  OK  ]
Starting cyrus-imapd: preparing databases... done.         [  OK  ]
[root@myserver root]# passwd cyrus
Changing password for user cyrus.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Adding mail accounts

[root@myserver root]# su - cyrus

-bash-2.05b$ whoami
cyrus

If you get a "cyradm: cannot connect to server" error you need to allow imap connections ( imaps isn't sufficient )

Create user named "test" using the cm = createmailbox command Then give the user "test" access to add and delete to the user mailbox

-bash-2.05b$ cyradm localhost
IMAP Password:
             localhost.localdomain> cm user.test

localhost.localdomain> lm
user/test (\HasNoChildren)

localhost.localdomain> setacl user.test test lrswipcd

localhost.localdomain> lam user.test
test lrswipcd

Configuring sendmail

For step 6, instead of using postfix, follow the example here to configure sendmail. Trying http://en.tldp.org/HOWTO/Cyrus-IMAP-7.html#ss7.3

Edit /etc/mail/sendmail.mc with care not to add extra spaces and add the following lines(do not copy and paste directly from this text as the tabs won't be added correctly):

MAILER(local)
MAILER(cyrus)
define(`confLOCAL_MAILER',`cyrus')
LOCAL_RULE_0
R$=N                   $: $#local $: $1
R$=N < @ $=w . >       $: $#local $: $1
Rbb + $+ < @ $=w . >   $#cyrusbb $: $1

Use tabs to separate the data (i.e. R$=N has three tabs between it and $: $#local $: $1) Then run:

m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf

Testing

Now 2 , step 7:

[root@myserver]# echo test_body | mail -s test_message test localhost

[root@myserver]# ls -al /var/spool/imap/t/user/test
total 24
drwx------  2 cyrus mail 4096 Jul 24 17:20 .
drwx------  5 cyrus mail 4096 Jul 21 18:55 ..
-rw-------  1 cyrus mail  729 Jul 24 17:20 1.
-rw-------  1 cyrus mail  668 Jul 24 17:20 cyrus.cache
-rw-------  1 cyrus mail  150 Jul 21 18:56 cyrus.header
-rw-------  1 cyrus mail  136 Jul 24 17:20 cyrus.index

root@myserver]# more /var/spool/imap/t/user/test/1.

Return-Path:
Received: from myserver ([unix socket])
       by myserver (Cyrus v2.2.3-Red Hat 2.2.3-11) with LMTP; Sat, 24 Jul 2004 17:20:08 -0400
X-Sieve: CMU Sieve 2.2
Return-Path:
Received: from myserver.local (localhost.localdomain [127.0.0.1])
       by myserver.local (8.12.11/8.12.11) with ESMTP id i6OLK7Hv007338;
       Sat, 24 Jul 2004 17:20:08 -0400
Received: (from root@localhost)
       by myserver.local (8.12.11/8.12.11/Submit) id i6OLK7gB007335;
       Sat, 24 Jul 2004 17:20:07 -0400
Date: Sat, 24 Jul 2004 17:20:07 -0400
From: root
Message-Id: <200407242120.i6OLK7gB007335@myserver.local>
To: [email]localhost@myserver.loca[/email]l, [email]test@myserver.loca[/email]l
Subject: test_message

test_body

I then sucessfully attached mozilla from a workstation on the same private network to this cyrus server.

Restore & Reconstruct

/var/spool/imap/t/user/test/
reconstruct -f user.test

Next

next steps: allowing mail to be accepted from outside localhost, forwarding mail from a firewall to a cyrus server inside the firewall.

openldap

References:

Install:

yum -y install openldap openldap-clients openldap-servers

Configure:

/etc/openldap/ldap.conf
/etc/openldap/slapd.conf 

Root Password:

slappasswd

spam filtering

Restore

To backup all mail and configuration files from a cyrus installation, rsync the following files and directories:

/etc/cyrus.conf
/etc/imapd.conf
/etc/pki/cyrus-imapd/
/etc/pki/tls/certs/
/etc/sysconfig/saslauthd
/var/spool/imap/

Restoring mail to a single user:

  • make sure user directory exists, if not create it
  • rsync files to user directory, for example: /var/spool/imap/t/user/test/
  • reconstruct mailboxes
su - cyrus -c /usr/lib/cyrus-imapd/reconstruct -f user.test

If all folders do not appear in the imap client, see if the folders are unsubscribed and resubscribe to them.


This page has been accessed 1786 times. This page was last modified 23:05, 30 Jan 2008.

Personal tools