[Dovecot] Deliver mail as 'read'?

Andrew Schulman andrex at alumni.utexas.net
Mon Jul 21 22:31:45 EEST 2008


> On Mon, 2008-07-21 at 06:42 +0100, Peter Collinson wrote:
> > I'd like to be able to deliver certain mail as 'read'  from procmail.  
> 
> Only way I can think of would be with a Sieve script that uses the
> imap4flags extension to set the flag \seen.

Yes, that's what I did.  I wanted to file all identified spam into the user's
Junk folder, and mark it as read.  You can do it with sieve using the imap4flags
extension, but you have to use deliver as the LDA since that's the only one that
supports imap4flags AFAIK.

At first I set up exim to do this automatically, and it worked but it took
several steps to set up.  

Later I decided to let each user create a rule in their sieve scripts to do
this, so that they could override it by putting their whitelist rule first.  The
rule is simple to specify in e.g. Ingo, if you have that set up for your users
to create their sieve scripts.  Ingo generates the following sieve fragment:

# spam
if exists "X-Spam-Flag"  {
    addflag "\\Seen";
    fileinto "Junk";
    removeflag "\\Seen";
    stop;
}

There is another way, though.  I used to mark messages "read" in kind of an ugly
way in maildrop, using an external call to formail(1), which comes with procmail
(at least on Debian).  See below.

Good luck,
Andrew.

# .mailfilter excerpt:
# spam filter
SPAMDIR=$HOME/.mail/.Junk
xfilter spamc   # SpamAssassin
if ( /^X-Spam-Flag: YES/ )
{
    # mark as Read
    xfilter "formail -I\"Status: R\""
    # deliver to the spam folder
    cc "$SPAMDIR"
    # mark it Read (in fact, mark all new spam messages as Read)
    foreach (`ls $SPAMDIR/new`) =~ /[^ ]+/
    {
        exception {
            `cd $SPAMDIR && mv "new/$MATCH" "cur/${MATCH}:2,S"`
        }
    }
    exit
}



More information about the dovecot mailing list