Sieve Advice Needed, Please

Casey Bralla MailList at
Fri Oct 24 02:26:13 UTC 2014

Anybody here familiar with the Sieve language?

I'm rebuilding my mail server, and I am working with the sieve language to
automatically filter spam into a separate account.  However, I've hit a
snag that I can't get around.

BTW, I'm using a clean install of dovecot, postfix, spamassassin on Debian 7.5.

I want to do server-side spam filtering, so I've got spamasassin
identifying spam, and then have sieve sorting the mail to a special spam
folder.   I can easily send spam to special folder in the inbox for each
mail user, but I wanted to have a single mail account for spam.   I can use
the "redirect" sieve command to send anything with the X-spam-flag set, but
this triggers an error and bounces the offending mail.   The bounce message

From: MAILER-DAEMON at (Mail Delivery System)
To: casey at
Subject: Undelivered Mail Returned to Sender
Date: Sun, 19 Oct 2014 16:41:49 -0400 (EDT)

This is the mail system at host

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to postmaster.

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

                   The mail system

<spam at>: mail forwarding loop for
    spam at

From: casey at
Date: Sun, 19 Oct 2014 16:41:20 -0400 (EDT)


I think this is a recursion problem, since the redirected mail has to go
through the spamassassin check and sieve again.   I tried to get clever and
prevent the recursion, but I'm not clever enough.  Here is my sieve rule

# A rule to move spam to the spam user
#  based on spamassassin setting the spam flag
# require ["redirect"]; (Not needed, since it is part of the basis sieve
# rule:[SPAM]
if header :contains "X-Spam-Flag" ["YES"]
        if address :is "to" "Spam at" 
                redirect "spam at";

Anybody able to give me any advice?  TIA


Casey Bralla

Chief Nerd in Residence
The NerdWorld Organisation

More information about the dovecot mailing list