Sam Varshavchik | 1 Apr 2006 01:27
Gravatar

Re: Syntax Check for maildrop(1) ?

Brian A. Seklecki writes:

> 
> Ideas on a syntax check (not a logic check; just validate ~/.mailfilter 
> syntax).

Pipe /dev/null to maildrop's standard input.  It won't actually deliver 
anything, just validate .mailfilter.

Ron Johnson | 2 Apr 2006 06:39
Picon
Gravatar

Getting lookup() to work

Hi,

http://www.courier-mta.org/?maildropfilter.html
    if (lookup(expr, file, "option"))
    {
       ...
    }

Relevant snippets from my ~/.mailfilter are:
    import USER
    killfile = "$HOME/killfile";
    sender = getaddr($FROM)
    if ( /To:.*/ ) && ( lookup($sender, $killfile) )
    {
        to "Maildir/.Trash"
    }

I'm trying to create a killfile, but am getting an error:

root <at> haggis:~# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------ 
2B5841CD5C3     5176 Sat Apr  1 22:32:21
sentto-13202574-5368-1143952257-ron.l.johnson=cox.net <at> returns.groups.yahoo.com
    (temporary failure. Command output: .mailfilter(13): Syntax error
after ))
                                         me <at> haggis

In my real ~/.mailfilter, the lookup() is on line 13.

What could I be doing wrong?
(Continue reading)

mouss | 2 Apr 2006 12:33
Favicon

Re: Getting lookup() to work

Ron Johnson wrote:
>     if ( /To:.*/ ) && ( lookup($sender, $killfile) )
>   
check the 'if' syntax (parens missing above).

if (/To:.*/ && lookup($sender, $killfile))

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
Ron Johnson | 3 Apr 2006 03:37
Picon
Gravatar

Re: Getting lookup() to work

On Sun, 2006-04-02 at 12:33 +0200, mouss wrote:
> Ron Johnson wrote:
> >     if ( /To:.*/ ) && ( lookup($sender, $killfile) )
> >   
> check the 'if' syntax (parens missing above).
> 
> if (/To:.*/ && lookup($sender, $killfile))

Thanks.  This doesn't throw syntax errors anymore:
    import USER
    killfile = "$HOME/killfile";
    sender = getaddr($FROM)
    log "Sender is |$sender|"
    log "killfile is $killfile"
    if ( ( /From:.*/ ) && ( lookup($sender, $killfile) ) )
    {
        to "Maildir/.Trash"
    }

It still doesn't work as a killfile, though.  Any thoughts?

--

-- 
-----------------------------------------------------------------
Ron Johnson, Jr.
Jefferson, LA USA

"They ginned up a war with an empty gun."
Chris Matthews, regarding Saddam Hussein & Iraq

-------------------------------------------------------
(Continue reading)

Christian Lerrahn | 3 Apr 2006 08:32

Re: Problems with regular expressions

Hi Thorsten,
> >> >Let's say I want to filter out all emails coming from abc <at> def.com. I
> >> >tried the following.
> >> >
> >> >/From:\s+.*abc <at> def\.com/
> >> >/From: *abc <at> def.com/
[snip]
> >> Matching mail adresses is not trivial. Friedl has a regex for this in
> >> his book which is one solid page long. Others say it can't be done at
> >> all.
> >
> >Why is that such a problem? It can be easily done in procmail.
> 
> What regex?
> 
> One of the reasons is that adresses have recursive elements, regexes
> don't. Also, things like
>     abc <at> def.com <xyz <at> axample.com>
> tend to be interesting.
> 
> 
> >Why are the examples in the maildrop documentation not working? At
> >least one of the examples I gave was from the docs.
> 
> Which one?

man 7 maildropex gives the example

if (/^From: *boss <at> domain\.com/ \ 
    && /^Subject:.*[:wbreak:]project status[:wbreak:]/)
(Continue reading)

Thorsten Haude | 3 Apr 2006 09:02
Picon

Re: Problems with regular expressions

Hi,

* Christian Lerrahn wrote (2006-04-03 16:32):
>> >Why are the examples in the maildrop documentation not working? At
>> >least one of the examples I gave was from the docs.
>> 
>> Which one?
>
>man 7 maildropex gives the example
>
>if (/^From: *boss <at> domain\.com/ \ 
>    && /^Subject:.*[:wbreak:]project status[:wbreak:]/)
>{
>    cc "!john"
>    to Mail/project
>}
>
>This is essentially the same as what I tried, just that the . is escaped
>and there's a second rul.

Well, this is example *will* match certain mails, but I think it's a
bad one for the reasons just demonstrated.

>> >> Anyway, for the case you mention above, try /^From:.*?abc <at> def.com$/.
>> >
>> >Ok, I'll try that. But why does the .* have to be greedy?
>> 
>> It ain't. The ? makes it explicitly ungreedy. (I guess, I never
>> actually used the later versions of Maildrop.)
>> 
(Continue reading)

Christian Lerrahn | 3 Apr 2006 15:36

Re: Problems with regular expressions

Hi Thorsten,
> >Let's say I want to filter out all emails coming from abc <at> def.com. I
> >tried the following.
> >
> >/From:\s+.*abc <at> def\.com/
> >/From: *abc <at> def.com/
> >
> >However, the only thing I ever got to work was something like
> >
> >/From: abc <at> def.com/
> >
> >Now the line might also be "ABC" <abc <at> def.com> and this doesn't match any
> >more. From what the documentation said, everything looked to me pretty
> >much like perl regexps but obviously this is not exactly true. How would
> >the correct rule be written?
> 
> How about using $FROM? Maildrop already gets the "Message envelope
> sender" for you, so just check on that.

Even that I don't get to work. I'm not sure if just the FROM variable
is not set correctly but at least "man 7 maildropfiler" says that this
might happen... :(

Christian

--

-- 
PGP key available at http://www.penpal4u.net/keys/Christian_Lerrahn.asc . 

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
(Continue reading)

mouss | 3 Apr 2006 18:34
Favicon

Re: Getting lookup() to work

Ron Johnson wrote:
> On Sun, 2006-04-02 at 12:33 +0200, mouss wrote:
>   
>> Ron Johnson wrote:
>>     
>>>     if ( /To:.*/ ) && ( lookup($sender, $killfile) )
>>>   
>>>       
>> check the 'if' syntax (parens missing above).
>>
>> if (/To:.*/ && lookup($sender, $killfile))
>>     
>
> Thanks.  This doesn't throw syntax errors anymore:
>     import USER
>     killfile = "$HOME/killfile";
>     sender = getaddr($FROM)
>     log "Sender is |$sender|"
>     log "killfile is $killfile"
>     if ( ( /From:.*/ ) && ( lookup($sender, $killfile) ) )
>   
last time it was a To:.* instead of a From:.*. In both cases this is 
useless, because almost all mail have a From and a To header.

are you after a
    if ($FROM, $somefile)
instead?

>     {
>         to "Maildir/.Trash"
(Continue reading)

Ron Johnson | 3 Apr 2006 18:59
Picon
Gravatar

Re: Getting lookup() to work

On Mon, 2006-04-03 at 18:34 +0200, mouss wrote:
> Ron Johnson wrote:
> > On Sun, 2006-04-02 at 12:33 +0200, mouss wrote:
> >   
> >> Ron Johnson wrote:
> >>     
> >>>     if ( /To:.*/ ) && ( lookup($sender, $killfile) )
> >>>   
> >>>       
> >> check the 'if' syntax (parens missing above).
> >>
> >> if (/To:.*/ && lookup($sender, $killfile))
> >>     
> >
> > Thanks.  This doesn't throw syntax errors anymore:
> >     import USER
> >     killfile = "$HOME/killfile";
> >     sender = getaddr($FROM)
> >     log "Sender is |$sender|"
> >     log "killfile is $killfile"
> >     if ( ( /From:.*/ ) && ( lookup($sender, $killfile) ) )
> >   
> last time it was a To:.* instead of a From:.*. In both cases this is

Yeah.  the "To: " field will never have names from my killfile
in it...

> useless, because almost all mail have a From and a To header.
> 
> are you after a
(Continue reading)

mouss | 3 Apr 2006 21:03
Favicon

Re: Getting lookup() to work

Ron Johnson wrote:
> On Mon, 2006-04-03 at 18:34 +0200, mouss wrote:
>   
>> Ron Johnson wrote:
>>     
>>> On Sun, 2006-04-02 at 12:33 +0200, mouss wrote:
>>>   
>>>       
>>>> Ron Johnson wrote:
>>>>     
>>>>         
>>>>>     if ( /To:.*/ ) && ( lookup($sender, $killfile) )
>>>>>   
>>>>>       
>>>>>           
>>>> check the 'if' syntax (parens missing above).
>>>>
>>>> if (/To:.*/ && lookup($sender, $killfile))
>>>>     
>>>>         
>>> Thanks.  This doesn't throw syntax errors anymore:
>>>     import USER
>>>     killfile = "$HOME/killfile";
>>>     sender = getaddr($FROM)
>>>     log "Sender is |$sender|"
>>>     log "killfile is $killfile"
>>>     if ( ( /From:.*/ ) && ( lookup($sender, $killfile) ) )
>>>   
>>>       
>> last time it was a To:.* instead of a From:.*. In both cases this is
(Continue reading)


Gmane