[Dovecot] dovecot-sieve with FreeBSD
Xueron Nee
xueron at gmail.com
Wed Sep 6 13:01:58 EEST 2006
Dear Rui Lopes,
Greet. I am looking for a sieve tutorial like this for a long time. And
this is what I need :)
Thanks.
Rui Lopes wrote:
> Hi,
>
> Peter Bauer wrote:
> > Hello,
> >
> > I've a test system with postfix (SMTP), dovecot (IMAP only) and covecot-LDA (MDA) under FreeBSD-6.1. Currently everything works fine. But I wasn't able to install dovecot-sieve from the CVS. Does anyone has a small documentation howto install dovecot-sieve on FreeBSD.
>
>
> Here are my little notes I've wrote while installing and testing. I'm
> still testing though, so, if you (or anyone else ;) find anything wrong,
> have questions, give feedback!
>
>
> == Sieve plugin for dovecot LDA
>
> * libsieve comes from the cyrus imap server (mail/cyrus-imapd23)
>
>
> Obtain the sieve plugin from CVS:
>
> cvs -d :pserver:anonymous at dovecot.org:/home/cvs co dovecot-sieve
>
>
> On FreeBSD change the autogen.sh file contents to:
>
> # using automake19, autoconf259, and libtool15 ports.
> aclocal19 -I /usr/local/share/aclocal
> autoheader259
> libtoolize --force
> automake19 --add-missing
> autoconf259
>
> Then, run it:
>
> ./autogen.sh
>
>
> Install this sieve plugin:
>
> # NB: Before you continue, make sure you didn't clean the dovecot
> # port when you've build it, eg: built it using:
> #
> # cd /usr/ports/mail/dovecot/ && make install
> #
> # You can clean it after you've build the sieve plugin though.
>
> ./configure \
> --prefix=/usr/local \
> --with-dovecot=/usr/ports/mail/dovecot/work/dovecot-1.0.rc7
> make install
>
>
> Configure dovecot to use the sieve plugin:
>
> vim /usr/local/etc/dovecot.conf
> protocol lda {
> ...
> mail_plugins = cmusieve # ... other plugins
> ...
> }
>
>
> Make a test sieve script:
>
> cat <<"EOF" > /var/vmail/two.example.com/rgl/.dovecot.sieve
> require ["fileinto", "reject", "vacation"];
> # * A sieve script is UTF-8 encoded.
> #
> # * folders are automatically created by the "fileinto" action.
> #
> # * By default (when no :comparator argument is given) all string
> # comparations are case-insensitive (in the ASCII range;
> # :comparator "i;ascii-casemap").
> # See the "2.7.3. Comparators" section at
> # http://www.ietf.org/internet-drafts/draft-ietf-sieve-3028bis-09.txt
> #
> # See sieve information at
> # http://www.ietf.org/html.charters/sieve-charter.html
> # For "vacation" see
> # http://ietfreport.isoc.org/idref/draft-ietf-sieve-vacation/
>
>
> # Moved SPAM marked messages to the Spam folder and stop processing.
> if header "X-Spam-Flag" "YES" {
> fileinto "Spam";
> stop;
> }
>
> # Move all mailer-daemon@ into a subfolder
> if header
> :contains
> ["To", "Cc", "Bcc", "Reply-To", "In-Reply-To"]
> [
> "mailer-daemon at two.example.com",
> "mailer-daemon at example.com",
> "mailer-daemon at turbina.example.com"
> ] {
> fileinto "mailer-daemon";
> stop;
> }
>
> # OR, using :matches:
>
> if header
> :matches
> ["To", "Cc", "Bcc", "Reply-To", "In-Reply-To"]
> ["mailer-daemon@*"] {
> fileinto "mailer-daemon";
> stop;
> }
>
> # move all mail @foxie.example.com to a subfolder.
> if header :matches "To" "*@foxie.example.com" {
> fileinto "foxie";
> stop;
> }
>
>
> # Some misc. tests follow.
>
> if header :contains "subject" ["test1", "test3"] {
> fileinto "test-odd";
> } elsif header :contains "subject" ["test2", "test4"] {
> fileinto "test-even";
> } elsif header "subject" "reject" {
> reject "reject test!";
> } elsif header "subject" "discard" {
> # discarded message are silently droped.
> discard;
> } elsif header "subject" "redirect" {
> # this will redirect the message to "root" user, without storing the
> # message in our mailbox.
> # NB: Because, in my case, the "postmaster" is an alias to this same
> # mailbox, so we also test the loop prevention mechanism of
> # dovecot LDA.
> # AND in this case we will NOT receive any message on our email
> # box.
> # sent emails ids are stored inside ~/.dovecot.lda-dupes
> redirect "postmaster at two.example.com";
> } elsif header "subject" "redirect to bob" {
> redirect "bob at two.example.com";
> } elsif header "subject" "vacation" {
> # sent emails ids are stored inside ~/.dovecot.lda-dupes in order to
> # detect loops.
> # List of auto replied senders are also stored here in order to
> # prevent multiple replies to the same sender for a given period of
> # time (defaults to 7 days [see src/libsieve/sieve.y]; min is 1 day,
> # max is 31 days)
> vacation "I'm out! I'll reply when I get back";
> }
> EOF
>
> NB: Errors on the sieve script are reported on the maillog and in a
> file named .dovecot.sieve.err near the normal .dovecot.sieve.
>
>
> # In this little "tests", I have several test mailboxes, like
> # rgl at two.example.com, alice at two.example.com, etc, which are handled by
> # dovecot LDA with a sieve script.
>
> printf 'Subject: test1\n\ntesting!\n' | sendmail rgl at two.example.com
>
> printf 'Subject: reject\n\ntesting!\n' | sendmail rgl at two.example.com
>
> printf 'Subject: discard\n\ntesting!\n' | sendmail rgl at two.example.com
>
> printf 'Subject: redirect\n\ntesting!\n' \
> | sendmail -f alice at two.example.com rgl at two.example.com
>
> printf 'Subject: redirect to bob\n\ntesting!\n' \
> | sendmail -f alice at two.example.com rgl at two.example.com
>
> printf 'Subject: test2\nX-Spam-Status: Yes\n\ntesting!\n' \
> | sendmail rgl at two.example.com
>
> printf 'Subject: vacation\n\ntesting!\n' \
> | sendmail -f alice at two.example.com rgl at two.example.com
>
>
> HTH,
> Rui Lopes
--
Xueron Nee <xueron at gmail.com>
More information about the dovecot
mailing list