Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Stephan Bosch

 Op 17-9-2010 10:27, Dieter Knopf schreef:

Hello,

I just migrated from Postfix/Courier/Maildrop to
Postfix/Dovecot/Deliver/Sieve and don't unterstand the right syntax
for sieve :(
I searched and found many small examples and many links to the RFC,
but nothing was usefull for me (or i didn't unterstand it)

I installed the latest Dovecot-Sieve (hg).

Examples from my maildrop config:


I've never used maildrop before, but using its docs and some guesswork 
I'll give it a go. The mentioned folder names may depend on your 
namespace config, particularly in terms of a INBOX prefix; use whatever 
is used in IMAP. The scripts below are a little more verbose than 
necessary, as I always explicitly list the :is match type.


require fileinto;
require subaddress;  /* for the :domain part (last script) */


# Filter FROM
if($E =~ /n...@domain1\.tld/)
{
  to $M/.Friends.Name1/
}


if address :is from n...@domain1.tld {
  fileinto Friends.Name1;
}


# Filter FROM with OR
if($E =~ /na...@domain1\.tld/ || $E =~ /na...@domain2\.tld/)
{
  to $M/.Friends.Name2/
}


if anyof (
  address :is from na...@domain1.tld,
  address :is from na...@domain2.tld) {
  fileinto Friends.Name2;
}

Or equivalently and much shorter:

if address :is from [na...@domain1.tld,na...@domain2.tld] {
  fileinto Friends.Name2;
}


# Filter Mailinglists
if (/^List-Id: .*sylpheed\.sraoss\.jp/)
{
  to $M/.ML.Sylpheed/
}


if header :contains list-id sylpheed.sraoss.jp {
fileinto ML.Sylpheed;
}

# Filter FROM AND SUBJECT
if($E =~ /fn...@domain.tld/  /^Subject: *foo/)
{
  to $M/.foo/
}


if allof (
  address :is from fn...@domain.tld,
  /* Space between field name and value is trimmed implicitly */
  header :matches subject foo* )
{
  fileinto foo;
}


# Filter TO
  if (hasaddr(n...@domain.tld))
  {
to $M/.foo/
  }


if address :is :comparator i;ascii-casemap
  [|to|, |cc|,| resent-to|, |resent-cc|]
  [n...@domain.tld] {
  fileinto foo;
}


# Or something like this:
if($E =~ /@facebookmail\.com/)
{
  if (/^Subject: .*invited you to join the group/)
  {
to $M/.Facebook.Invites.Groups/
  }
  if (/^Subject: .*invited you to the event/)
  {
to $M/.Facebook.Invites.Events/
  }
}


if address :is :domain from facebookmail.com {
   if header :matches subject invited you to join the group* {
  fileinto Facebook.Invites.Groups;
   } elseif header :matches subject invited you to the event* {
  fileinto Facebook.Invites.Events;
   }
}


Is that possible?

Yes, given the above examples.


Or is maildrop simple more powerful?

Maildrop is more powerful, particularly because it can execute arbitrary 
binaries. For security reasons, Sieve doesn't support that at all. But, 
since you are not using such functionality, your migration should be 
problem-free.



Thank you :-)

PS: The above scripts were produced in an ad-hoc fashion. I haven 
bothered to do syntax checking.


Regards,

Stephan.


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Stephan Bosch

 Op 17-9-2010 12:18, Stephan Bosch schreef:



# Filter TO
  if (hasaddr(n...@domain.tld))
  {
to $M/.foo/
  }


if address :is :comparator i;ascii-casemap
  [|to|, |cc|,| resent-to|, |resent-cc|]
  [n...@domain.tld] {
  fileinto foo;
}


Iew! Not sure where these '|' chars came from, but these are obviously 
not supposed to be there:


if address :is :comparator i;ascii-casemap
  [to, cc, resent-to, resent-cc]
  [n...@domain.tld] {
  fileinto foo;
}

Regards,

Stephan.



Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Stephan Bosch

 Op 17-9-2010 12:18, Stephan Bosch schreef:

require subaddress;  /* for the :domain part (last script) */



Shameful. No, you don't need to require this. The :domain part is part 
of the core language. Let's just say it was early. :)


Regards,

Stephan.



Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Dieter Knopf
2010/9/17 Stephan Bosch step...@rename-it.nl:
  Op 17-9-2010 12:18, Stephan Bosch schreef:
[...]

THANKS for the big help. Converting it now :-)

But have another problem with the fileinto-command  :(

I alway get a failed to find namespace for mailbox 'foo'
but/home/vmail/domain.tld/name/.foo/ exist.
I tried it with:
fileinto foo; and fileinto .foo;

I think it's because of my old courier maildir structure.

My maildir looks like:
/home/vmail/domain.tld/name/cur/
/home/vmail/domain.tld/name/new/
/home/vmail/domain.tld/name/.Foo/
/home/vmail/domain.tld/name/.Foo.Foo1/
/home/vmail/domain.tld/name/.Foo.Foo2/
/home/vmail/domain.tld/name/.Foo.Foo.Foo/


IMAP works fine with:
namespace private {
  separator = .
  prefix = INBOX.
  inbox = yes
}

(but i don't have any files/directories beginning with INBOX.)
I tried to change the prefix to  and . but then i can't access any
folder. Folders only works with INBOX.

Any idea what's the right way with my maildir structure?

Thank you!

Dieter


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Patrick Westenberg

Dieter Knopf schrieb:


I alway get a failed to find namespace for mailbox 'foo'
but/home/vmail/domain.tld/name/.foo/ exist.
I tried it with:
fileinto foo; and fileinto .foo;


This works for me:

fileinto :create INBOX.foo;

:create will create this folder if it does not exist.

Patrick


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Dieter Knopf
2010/9/17 Patrick Westenberg p...@wk-serv.de:
 This works for me:

 fileinto :create INBOX.foo;

 :create will create this folder if it does not exist.

Thanks, works fine now :-)

One small issue:
My mail client (kmail) always want to open the INBOX.dovecot.sieve
(because there is a .dovecot.sieve file for the filter). (Client show
it as dovecot/sieve folder)

Is there a way to hide this?

Thanks


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Patrick Westenberg

Dieter Knopf schrieb:


One small issue:
My mail client (kmail) always want to open the INBOX.dovecot.sieve
(because there is a .dovecot.sieve file for the filter). (Client show
it as dovecot/sieve folder)

Is there a way to hide this?


I never had this problem because I use home directories.

User specific sieve files are placed in the home directories while
mails are stored in the given mail_location (can be a subdirectory
of the home directory)

mail_location = mdbox:~/mdbox

endeavour:/var/mail/example.com/mail# ls -la
insgesamt 24
drwxr-x---  4 vmail vmail 4096  6. Sep 13:57 .
drwxr-x--- 10 vmail vmail 4096  6. Sep 15:17 ..
-rw---  1 vmail vmail  452  6. Sep 13:24 .dovecot.sieve.log
-rw---  1 vmail vmail  189  6. Sep 13:25 .dovecot.svbin
drwx--  4 vmail vmail 4096 11. Sep 01:06 mdbox



Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Dieter Knopf
2010/9/17 Patrick Westenberg p...@wk-serv.de:
 User specific sieve files are placed in the home directories while
 mails are stored in the given mail_location (can be a subdirectory
 of the home directory)

Thanks. I tested something and set a sieve-config outside my maildirs:
# dovecot -n |grep sieve
sieve: /home/vmail-sieve/%u/main.filter
sieve_dir: /home/vmail-sieve/%u/
sieve_global_dir: /home/vmail-sieve/global/

Works fine, except i can't include files from sieve_global:
I have a file in /home/vmail-sieve/m...@domain.tld/main.filter with:
require [fileinto, include];
include :global spam.filter;

/home/vmail-sieve/global/spam.filter exists

Errors:
Error: sieve: failed to open script
/home/vmail-sieve/n...@domain.tld/main.filter (view logfile
/home/vmail-sieve/n...@domain.tld/main.filter.log for more
information)
Log:
main_script: line 2: error: included global script 'spam.filter' does not exist.
main_script: error: validation failed.

I though :global searches inside the sieve_global_dir? Or is there a
way to debug errors like this better?

Thanks


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Patrick Westenberg

Dieter Knopf schrieb:


Sorry for the question, just found it out, I didn't knew that all
files needs a .sieve extensions.
include :global foo; with a file foo.sieve works fine :-)


Good to know ;)


Re: [Dovecot] Too stupid for sieve (former maildrop user)

2010-09-17 Thread Stephan Bosch

 On 9/18/2010 1:10 AM, Patrick Westenberg wrote:

Dieter Knopf schrieb:


Sorry for the question, just found it out, I didn't knew that all
files needs a .sieve extensions.
include :global foo; with a file foo.sieve works fine :-)


Good to know ;)


Good point. I now clarified this in the wiki.

Regards,

Stephan.