Skip to topic | Skip to bottom
Home
Freebsd
Freebsd.SendMailAndCyrusr1.5 - 19 Dec 2004 - 17:18 - TWikiGuesttopic end

Start of topic | Skip to actions



Part 1: Installing CyrusImapd?

Installing CyrusImapd? on FreeBSD is pretty simple:

  1. portinstall mail/cyrus-imapd2
  2. Edit /usr/local/etc/imapd.conf to suit your needs (the defaults are probably sufficient)
  3. Run the /usr/local/cyrus/bin/mkimap command to build the appropriate file hierarchy
  4. Set the password of the cyrus user: passwd cyrus
  5. Start the imapd and sasl services:
    • /usr/local/etc/rc.d/imapd.sh start
    • /usr/local/etc/rc.d/sasl.sh start
  6. su cyrus
  7. cyradm localhost and use the password you just defined
  8. Use the cm command inside cyradm to create all of the mailboxes you want to use. Example: cm user.somemailuser
  9. Quit cyradm
  10. Use /usr/local/bin/saslpasswd2 to set passwords on the accounts you just created. Example: saslpasswd2 -c somemailuser

Now you can test this by creating a simple mail file:

# cat testmail
To: somemailuser
From: someoneelse
Subject: Test email

This is a test

and sending it to cyrus' deliver program:

# cat testmail | /usr/local/cyrus/bin/deliver -a somemailuser -m user.somemailuser

Then, use any standard mail client (or telnet, if you prefer) to verify that the email was delivered to somemailuser's account.

Part 2: Configuring Sendmail

Using Cyrus for local delivery

If you want to use Cyrus to deliver mail locally (and most people do):

  • If you haven't already done so, create a LocalSendmailConfiguration.
  • Edit your SendMail config file. Locate the MAILER(local) line near the bottom. Just before that line, insert two new lines:
define(`confLOCAL_MAILER',`cyrusv2')
MAILER(cyrusv2)
  • Your new configuration file should look something like this:
/root# cd /etc/mail; tail -n 4 host.domain.com.mc
define(`confLOCAL_MAILER',`cyrusv2')
MAILER(cyrusv2)
MAILER(local)
MAILER(smtp)
  • Install your new configuration:
/etc/mail# make; make install; make restart

A Note About SpamAssassin

If you want to use SpamAssassin with your new setup, then follow the instructions at FilterMailWithSpamAssassin to install it. I highly recommend using the FilterMailWithSpamAssassinViaMilter method of using a SendMail "milter" to process your mail. It's far easier to configure and is completely independent of your SendMailAndCyrus setup. However, if you have a firmly entrenched ProcMail? setup, then you'll want to work through the following directions.

Using ProcMail for local delivery with SpamAssassin

ProcMail cannot deliver directy to a CyrusImapd? mail folder. However, you can configure it to use cyrus' deliver program to handle the actual delivery.

If you're using ProcMail to send email through SpamAssassin before delivery, read the SpamAssassinAndCyrus topic and then follow the steps below.

If you need to use ProcMail to sort your mail, then:

SendMail? configuration

  • If you haven't already done so, create a LocalSendmailConfiguration.
  • Edit your SendMail config file. Locate the MAILER(local) line near the bottom. Just before that line, insert a new lines:
FEATURE(local_procmail)
  • Your new configuration file should look something like this:
/root# cd /etc/mail; tail -n 3 host.domain.com.mc
FEATURE(local_procmail)
MAILER(local)
MAILER(smtp)

Create the spam-processing pipe

Choose your approach. You can either create your own wrapper for spamc and deliver, or you can use mailcheck.py from SpamAssassin. Advantage of the first option: you don't have to have Python installed on the server. Advantage of the second option: it's easier, and spamcheck.py uses lmtp to deliver the email directly to cyrus instead of calling the deliver program. This allows you to use some of CyrusImapd?'s nifty features, such as SortingMailWithSieve?.

Option 1: Roll-your-own solution with spamc and deliver

# cat /usr/local/etc/procmailrc
DROPPRIVS=no

:0fw
| /usr/local/bin/procmail-cyrus-delivery.sh $LOGNAME
  • Create /usr/local/bin/procmail-cyrus-delivery.sh. The example below includes an inline call to spamc (from SpamAssassin), which is the original problem I was trying to solve by using ProcMail in this setup.
# cat /usr/local/bin/procmail-cyrus-delivery.sh
#!/bin/sh

LOGNAME=$1

formail -I"From " | spamc -u $LOGNAME | /usr/local/cyrus/bin/deliver -a $LOGNAME -m user.$LOGNAME
  • Make procmail-cyrus-delivery.sh executable: chmod a+x /usr/local/bin/procmail-cyrus-delivery

Option 2:

# cd /usr/ports/mail/p5-Mail-Sp
# make extract
# cp work/Mail-SpamAssassin-2.50/contrib/spamcheck.py /usr/local/bin/
# make clean

# cat /usr/local/etc/procmailrc
DROPPRIVS=no

:0fw

| /usr/local/bin/spamcheck.py -s nobody -r $LOGNAME -l unix:/var/imap/socket/lmtp

Putting the new setup into action

  • Install your new configuration:
/etc/mail# make; make install; make restart

Part 3: Testing!

Test your new setup immediately. If anything went wrong, you could possibly be losing mail. If it isn't verifiably working at this point, type cd /etc/mail; make stop to stop SendMail until you either correct the problem or revert to a previous working setup.

-- KirkStrauser - 03 Jul 2003

Alternative recipies

It is possible to make sendmail check existence of cysus mailboxes before replying to "RCPT TO:". The required configuration is described at Real Time Cyrus (and sendmail) Integration Version 2

Andrzej Adam Filip 2004-12-19


You are here: Freebsd > SendMailAndCyrus

to top

Copyright © 1999-2008 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Subwiki? Send feedback