Re: [exim] Problems testing (sieve) filter rules

Páxina inicial
Borrar esta mensaxe
Responder a esta mensaxe
Autor: Phil Pennock
Data:  
Para: Benjamin Podszun
CC: exim-users
Asunto: Re: [exim] Problems testing (sieve) filter rules
On 2008-02-07 at 20:32 +0100, Benjamin Podszun wrote:
> On Thu, 7 Feb 2008, Phil Pennock wrote:
> > On 2008-02-07 at 19:29 +0100, Benjamin Podszun wrote:
> >> (Running as root or trusted mail account)
> >>
> >> exim -bf testfilter < testmail
> >
> > You're missing "-t" to take recipients, etc, from the mail headers of
> > "testmail".
>
> $ exim -bf testfilter -t < testmail
> exim: incompatible command-line options or arguments


Oh, so it does. Sorry about that.

So, the default sender/recipient are taken from the calling user, and
then the recipient is assumed to have the test-filter you specify. Not
a problem.

Generally, Exim is careful to keep the SMTP envelope (or mock-up
thereof) separate from the message headers; if it did start extracting
routing values from a mail content without being explicitly requested to
do so, it would be doing something different from what it usually does
and causing even more confusion. Probably.

> >> Okay, two things make me nervous here:
> >> 1) Why is the recipient in this test the current user? I know that I can
> >> override/set that with -bfd/-bfl but I expected that exim takes these
> >> values from the testmail - to test the rules?
> >
> > Only if you tell it to. Otherwise the recipients are specified on the
> > command-line.
>
> Would love to tell it to use the sample mail somehow. But since I'm
> testing filter rules with a sample message, what's the message for if it
> isn't used for the addresses? Headers only by default? Anything at all?
> Sorry, I'm still lost here.


Because you can filter based upon properties of the message. Take a
look at RFC 5228, which is the current specification for Sieve and which
contains a number of examples.

Eg, you can filter based on the size of the message, content of various
headers (eg, Subject:), etc. You're not limited to just the envelope.

Eg, extracting from an old sieve file I have (used with Cyrus IMAP, not
with Exim):

----------------------------8< cut here >8------------------------------
if envelope :is "from" "cvs-changes-request@???" {
  if header :matches "Subject" ["CVS commit: home/pdp *", "CVS commit: home/pdp/*"] {
    fileinto "INBOX.cvs.mine"; stop;
  }
  fileinto "INBOX.cvs.misc"; stop;
}


if header :is "Content-Type" "text/html" {
fileinto "INBOX.html-only"; stop;
}

# implicit keep here
----------------------------8< cut here >8------------------------------

So the envelope check uses the values faked up, but the Subject: check
is using the content.