# dovecot and sieve scripts

## rogerdv

I want to discard all mail marked by spam assassin as spam before it gets to the users inbox. I tried sieve scripts, adn followed directions in Dovecot wiki.

i created this script (named default.sieve):

```
if header :contains "X-Spam-Flag" "YES" {

  discard;

} 
```

in /usr/lib/dovecot/sieve, configured dovecot plugin, 

```
protocol lda {

  # Support for dynamically loadable plugins. mail_plugins is a space separated

  # list of plugins to load.

  mail_plugins = cmusieve # ... other plugins like quota

  mail_plugins_dir = /usr/lib/dovecot/lda

}

plugin {

  sieve_global_path = /usr/lib/dovecot/sieve/default.sieve

}
```

But it doesnt works. also, no trace of error can be found in logs. Do I need some extra steps? Also noticed that sievec and sieve commands are not installed. I emerged dovecot 1.1.7 with sieve flag enabled, do I need to emerge anything else?

----------

## cach0rr0

same here. I'll post my info once I get home, but I did the same and never got this working either

I *do* seem to remember having to emerge sieve itself to get those scripts - never got it working though, currently having to deal with the PITA of making rules client-side

I also noticed it seemed sieve support had been dropped from cyrus-imapd too. I tried doing an ebuild for it, but that failed miserably, so I went back to dovecot =/

----------

## xces

 *rogerdv wrote:*   

> I want to discard all mail marked by spam assassin as spam before it gets to the users inbox.

 

Not really related to your problem, but you should consider to move the flagged mails to a seperate IMAP folder instead of just discarding the mails. False positives, anyone?

 *rogerdv wrote:*   

> But it doesnt works. also, no trace of error can be found in logs. Do I need some extra steps?

 

Are you actually using the Dovecot LDA to deliver the mails or are you using your MTA's (Postfix, Exim, ...) internal MDA to deliver them? You absolutely have to use the Dovecot LDA to make Sieve filter your mails.

 *rogerdv wrote:*   

> Also noticed that sievec and sieve commands are not installed. I emerged dovecot 1.1.7 with sieve flag enabled, do I need to emerge anything else?

 

The sieved and sievec binaries are not installed in $PATH but in /usr/libexec/dovecot/. You should find them there.

 *cach0rr0 wrote:*   

> I also noticed it seemed sieve support had been dropped from cyrus-imapd too.

 

That's news to me. My Cyrus IMAP installation works quite well with its timsieved, eventually...

----------

## cach0rr0

 *xces wrote:*   

> 
> 
> That's news to me. My Cyrus IMAP installation works quite well with its timsieved, eventually...

 

This was about a year ago that I was looking at it, and I'd assumed the removal was intentional for one reason or another? Ended up having to try and do my own ebuild, which ended up a nightmare. 

It wasn't in any of the ebuilds when I looked - and well, it is now it seems?

----------

## rogerdv

 *xces wrote:*   

>  *rogerdv wrote:*   I want to discard all mail marked by spam assassin as spam before it gets to the users inbox. 
> 
> Not really related to your problem, but you should consider to move the flagged mails to a seperate IMAP folder instead of just discarding the mails. False positives, anyone?
> 
>  *rogerdv wrote:*   But it doesnt works. also, no trace of error can be found in logs. Do I need some extra steps? 
> ...

 

Hmm, my mistake. Yes, Postfix is delivering the mail to the mailboxes. Ill have to google how to use dovecot for that.

----------

## mimosinnet

I have just been working on this. I have managed to have getmail -> procmail -> dovecot delivery with sieve. This is my getmail config:

```
[retriever]

type = SimplePOP3SSLRetriever

server = pop.gmail.com

port = 995

username = username

password = password

[destination]

type = MDA_external

# path = /usr/libexec/dovecot/deliver

path = /usr/bin/procmail 

user = mail

group = mail

unixfrom = true

arguments = ("-m", "/etc/procmailrcs/procmailrc")

[options]

verbose = 0

delete = true

message_log = ~/.getmail/log

read_all = true

```

----------

## M

 *Quote:*   

> Hmm, my mistake. Yes, Postfix is delivering the mail to the mailboxes. Ill have to google how to use dovecot for that.

 

Just set mailbox_command to dovecot lda binary.

----------

