By Wilddev
Version 1.0
This guide was inspired by the excellent guide written by beowulf here. Hopefully it will evolve as I add features and suggestions to it as beowulf's guide has.
I've noticed quite a few posts by people wishing to setup cyrus-imapd instead of alternatives for a mailserver. Cyrus is an excellent choice. It is used and development is sponsored by a large university (Carnegie Mellon) and is designed to be a scalable, secure and most of all fast imap server.
Preparation:
Server;
Make sure /etc/hostname and /etc/dnsdomainname are setup.
Emerging Packages;
Code: Select all
USE="ssl pam maildir sasl gdbm berkdb -mysql -ldap -mbox -postgres -kerberos -java -static" emerge cyrus-sasl cyrus-imapd cyrus-imap-admin Mail-SpamAssassin postfixPostfix;
Postfix configuration in general has been covered quite well both in the forums and in the user docs so I'll just outline what I have in my setup with little commentary. The main difference here is I'm using spamcheck from the spamassassin package as my mail transport to pass mail from postfix to spamassassin and then on to cyrus-imapd.
Postfix needs a link to the sasl directory;
Code: Select all
ln -s /etc/sasl2 /etc/postfix/sasl2Code: Select all
vi /etc/postfix/main.cf
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/lib/postfix
mail_owner = postfix
mydestination = $myhostname, localhost.$mydomain
unknown_local_recipient_reject_code = 450
alias_maps = hash:/etc/mail/aliases
alias_database = hash:/etc/mail/aliases
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail
newaliases_path = /usr/bin/newaliases
mailq_path = /usr/bin/mailq
setgid_group = postdrop
manpage_directory = /usr/share/man
sample_directory = /etc/postfix/sample
readme_directory = /usr/share/doc/postfix-2.0.11
mailbox_transport = spamcheck
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions =
reject_invalid_hostname,
reject_non_fqdn_hostname,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
reject_unauth_pipelining,
permit_sasl_authenticated,
permit_mynetworks,
check_relay_domains
reject_unauth_destination,
reject_rbl_client zombie.dnsbl.sorbs.net,
reject_rbl_client relays.ordb.org,
reject_rbl_client opm.blitzed.org,
reject_rbl_client list.dsbl.org,
reject_rbl_client sbl.spamhaus.org,
reject_rbl_client blackholes.easynet.nl,
permit
smtpd_helo_required = yes
broken_sasl_auth_clients = yes
smtpd_sasl_local_domain = $myhostnameCode: Select all
vi /etc/postfix/master.cf
smtp inet n - n - - smtpd
pickup fifo n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr fifo n - n 300 1 qmgr
tlsmgr fifo - - n 300 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
old-cyrus unix - n n - - pipe
flags=R user=cyrus argv=/usr/cyrus/bin/deliver -e -m ${extension} ${user}
cyrus unix - n n - - pipe
user=cyrus argv=/usr/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=foo argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
spamcheck unix - n n - - pipe
flags=R user=cyrus argv=/usr/lib/postfix/spamcheck.py -s ${sender} -r ${user} -l unix:/var/imap/socket/lmtpMove the smtpd.conf file into place;
Code: Select all
mv /etc/sasl2/smtpd-2.0.conf /etc/sasl2/smtpd.confCode: Select all
vi /etc/sasl2/smtpd.conf
pwcheck_method: auxpropMake the sasl2 database file;
Code: Select all
rm /etc/sasl2/sasldb2Code: Select all
/usr/sbin/saslpasswd2 -c -u host.wilddev.net -a smtpauth cyrus
Password:I setup my file perms a little differently to beowulf as I need both postfix and cyrus to be able to access the user database.
Protect the file and add cyrus and postfix to the mail and saslauth groups;
Code: Select all
chmod 660 /etc/sasl2/sasldb2Code: Select all
groupadd saslauthCode: Select all
vi /etc/group
mail::12:mail,cyrus,postfix
saslauth:x:441:cyrus,postfixCode: Select all
chown :saslauth /etc/sasl2/sasldb2Code: Select all
vi /etc/mail/aliases
# Well-known aliases -- these should be filled in!
root: joeCode: Select all
newaliasesCode: Select all
postfix checkCode: Select all
/etc/init.d/postfix startThe imapd config file should be mostly setup for you. Notice here we again use auxprop and not the saslauthd method suggested in the default file. This avoids us needing to use the saslauthd daemon to access pam.
Setup the imapd.conf file;
Code: Select all
vi /etc/imapd.conf
configdirectory: /var/imap
partition-default: /var/spool/imap
sievedir: /var/imap/sieve
tls_cert_file: /etc/cyrusimapd/server.crt
tls_key_file: /etc/cyrusimapd/server.key
admins: cyrus
hashimapspool: yes
allowanonymouslogin: no
sieveusehomedir: no
postmaster: postmaster
servername: host.wilddev.net
sendmail: /usr/sbin/sendmail
sasl_pwcheck_method: auxprop
sasl_mech_list: PLAIN
altnamespace: yes
unixhierarchysep: yesCode: Select all
vi /etc/cyrus.conf
START {
recover cmd="ctl_cyrusdb -r"
}
SERVICES {
imap cmd="imapd" listen="imap2" prefork=0
pop3 cmd="pop3d" listen="pop-3" prefork=0
imaps cmd="imapd -s" listen="imaps" prefork=0
pop3s cmd="pop3d -s" listen="pop3s" prefork=0
sieve cmd="timsieved" listen="sieve" prefork=0
lmtpunix cmd="lmtpd" listen="/var/imap/socket/lmtp" prefork=0
}
EVENTS {
checkpoint cmd="ctl_cyrusdb -c" period=30
delprune cmd="ctl_deliver -E 3" period=1440
tlsprune cmd="tls_prune" period=1440
}Setup user folders on server;
Code: Select all
/etc/init.d/cyrus startCode: Select all
cyradm --user cyrus localhost
cm user/joe@foo.dom
cm user/joe@foo.dom/Spam
sam user/joe@foo.dom/Spam anyone pSpamAssassin;
Setup the local.cf file (automated setup is available here.);
Code: Select all
mkdir /var/spool/spamassassinCode: Select all
vi /etc/mail/spamassassin/local.cf
auto_whitelist_path /var/spool/spamassassin/auto-whitelist
report_safe 0
use_terse_report 1
required_hits 4.0
bayes_ignore_header X-Spam-Report
bayes_ignore_header X-Spam-StatusCode: Select all
/etc/init.d/spamd startCode: Select all
cp spamd.py /usr/lib/postfixCode: Select all
cp spamcheck.py /usr/lib/postfixCode: Select all
postfix reloadLinks;
http://asg.web.cmu.edu/cyrus/imapd/
http://www.linuxjournal.com/article.php?sid=6998


