Setting up Cyrus-IMAP2 in FreeBSD
Install cyrus-imapd2 from /usr/ports/mail/cyrus-imapd2/
# cd /usr/ports/mail/cyrus-imapd2
# make all install
(when prompted for authentication options, select dbm3 and sasl.. note sometimes
you can get checksum errors..you can get rid of it by using nochecksum option)
Configuring IMAP:
1) Create /var/imap and /var/spool/imap
#mkdir /var/imap /var/spool/imap
#chown cyrus:mail /var/imap /var/spool/imap
#chmod 750 /var/imap /var/spool/imap
2) Edit /usr/local/etc/imapd.conf
Make sure you have the following:
configdirectory: /var/imap
partition-default: /var/spool/imap
sieveusehomedir: false
sievedir: /var/imap/sieve
admins: cyrus
allowanonymouslogin: no
sasl_pwcheck_method: saslauthd
3) Change to user cyrus and execute this
# su cyrus
% /usr/local/cyrus/bin/mkimap
This should create all the required directories with
proper permission.
4) Make sure you have the following in /etc/services
pop3
110/tcp
imap
143/tcp
imsp
406/tcp
acap
674/tcp
imaps
993/tcp
pop3s
995/tcp
kpop
1109/tcp
sieve
2000/tcp
lmtp
2003/tcp
fud
4201/udp
5) Remove any imap, imaps, pop3, pop3s, kpop, lmtp and sieve lines from
/etc/inetd.conf
6) Add the following lines to the end of /etc/syslog.conf
local6.debug
/var/log/imapd.log
auth.debug
/var/log/auth.log
7) Create the files by
# touch /var/log/imapd.log /var/log/auth.log
Now setup sendmail:
Go to /etc/mail
Add the following lines in your hostname.mc file
define(`confLOCAL_MAILER',`cyrusv2')
define(`CYRUS_MAILER_PATH',`/usr/local/cyrus/bin/deliver')
MAILER(`cyrusv2')
Then do,
#make stop
#make all
#make install
#make start
8) Start the saslauthd server by doing
#/usr/local/etc/rc.d/saslauthd.sh start
9) Start the IMAPD server (copy imapd.sh.sample to imapd.sh)
#/usr/local/etc/rc.d/imapd.sh start
10) Set the passwd for user cyrus
#saslpasswd2 cyrus
Enter the passwd:
11) Now su as cyrus and test the IMAP server
#su cyrus
%imtest -m login -p imap localhost
Enter the password, if you see OK. User logged in.. then the server is working..Press
. logout to exit..
12) Add user mailboxes by logging using cyradm
%cyradm localhost
localhost@xxxx>cm user.john
localhost@xxxx>quit
%exit
#
13) Now set passwd for john using saslpasswd2 (as root)
#saslpasswd2 john
EnterPasswd:
14) Woohoo that's it... Test from someother machine by doing a telnet to imap
port and see if you get something similar to this..
telnet 192.168.5.1 imap
Trying 192.168.5.1...
Connected to 192.168.5.1 (192.168.5.1).
Escape character is '^]'.
* OK sunwalker.isa-geek.org Cyrus IMAP4 v2.1.11 server ready
. logout
* BYE LOGOUT received
. OK Completed
Connection closed by foreign host.
15) For extra fun, install squirrelmail from /usr/ports/mail.. After installing
just go to /usr/local/squirrelmail/ and run ./configure to set a web-based
interface for your IMAP server.
UPDATES
Ney pointed out that he had to add this line in /etc/rc.conf to
make things work.
sasl_saslauthd_flags="-a sasldb"
So if you have any problems try adding this line to your /etc/rc.conf.
Configuring with ssl (by Tom Lazar)
Create a server key and certificate (we're wrapping both of this into
one file, although splitting would be possible)
su - cyrus
openssl req -new -x509 -nodes -out /var/imap/server.pem -keyout
/var/imap/server.pem -days 3650
Make sure the following options exist in /usr/local/etc/imapd.conf
sasl_pwcheck_method: auxprop # this should be the default, anyway
tls_key_file: /var/imap/server.pem
tls_ca_file: /var/imap/server.pem
tls_cert_file: /var/imap/server.pem
admins: cyrus
You might find the manuals at /usr/local/share/doc/cyrus-imapd2/ helpful.
Script to automate user account & mail box creation (by Amram Bentolila)
cyr_adduser.pl
This will create a new mailbox and set a quota on the new user. Just be
sure that you installed the Cyrus::IMAP perl module. If you did
'make all && make install' or installed Cyrus using the FreeBSD ports you
don't have to do anything at all. Change the params to match your mailserver settins, and
your good to go!
cyr_batchadd.sh
Batch add users for cyrus mailserver. Just specify a plain text file that has one user per line.
The only dependancy is the cyr_adduser.pl program.
Author: Amram Bentolila (amram@manhattanprojects.com)
Note: (Can't locate Cyrus/IMAP/Admin.pm)
If you get an error message: Can't locate Cyrus/IMAP/Admin.pm, make
sure that you have Cyrus::IMAP perl module installed and specify the
library path using "use lib" command at the start of the script.
Example: use lib "/opt/local/lib/perl5/site_perl/5.8.7/mach";
Questions/Comments: Email Venkatesh (venkat@soe.ucsc.edu)