procmail
[Top] [All Lists]

Re: existance of a field?

1997-05-21 06:09:00
On Tue, 20 May 1997 23:34:06 -0400 (EDT), 
Luke Davis <ldavis(_at_)voicenet(_dot_)com> wrote:
I would like to check for the existance of a field...
If it does exist, nomatter what the contents, the script is successfull;
if it isn't there, the script fails.

Do you mean to say, if the field is present in incoming mail, save it
to a folder, otherwise don't? That's easy:

    :0:
    * ^x-list-id:
    folder

But this is apparently not what you want. 

{
:0
* ^x-list-id:.*
listname | formail -rxx-list-id:

If `listname' is supposed to be the name of a folder, what is the
purpose of the formail part? If `listname' is the name of a script,
you need a leading pipe symbol.

If it's the first case, perhaps you could try this:

    :0
    * ^x-list-id:
    | formail -zxx-list-id: >>listname

This will extract the x-list-id field's value (without leading spaces;
omit the -z if you want to preserve them) to the file `listname' and
forget about the rest of the mail message (i.e. it will not be filed
anywhere, but Procmail will finish here nevertheless). While this is
perhaps not what you want, perhaps you can play around with this and
get it to do what you want.
  Here's an example which will keep the message around so you can file
it in some folder, and remember the value of the x-list-id field in
the LISTID variable:

    :0
    * ^x-list-id:([     ]*)\/[^  ]+
    {
        LISTID=$MATCH
    }

You could replace the stuff in the braces with something like this:

        LOG=" x-list-id: $MATCH
 "
        :0:
        somefolder

This will save the value of the x-list-id to Procmail's normal log
file, and save the message in the file `somefolder'. 

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Exis-t-e-n-c-e. Suc-c-e-s-s-f-u-l.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

<Prev in Thread] Current Thread [Next in Thread>