procmail
[Top] [All Lists]

Re: "if this then that" logic doesn't seem to work

2001-04-02 07:51:01
On  2 Apr, Jill Bird wrote:
| Can anyone help me with this?
| 
| testing.rc - INTENT is to check 2 items before checking the body. If the
| >From and Subject match - then check the body for a particular string (in
| this case: xxff).  If all of this matches, resend the message to a
| particular mail address AND put a copy in my mail folder OTHERWISE -
| just put a copy in my mail folder.
| 
| :0
| * ^From(_dot_)123247N(_at_)knotes(_dot_)kodak(_dot_)com
| * ^Subject:.*test
| {
|         :0 B
|         *xxff
|         :0 c
|         ! bird(_at_)cyber(_dot_)kodak(_dot_)com
|         :0
|         in-testing
| }
| 
| The log file shows the following:
| [...]

It's *so* refreshing to have someone include the relevant log output.
Each of these might have been clues:

| procmail: Skipped "! bird(_at_)cyber(_dot_)kodak(_dot_)com"
| procmail: Skipped "! bird(_at_)cyber(_dot_)kodak(_dot_)com"

and:
 
| procmail: Match on "^Subject:.*test"
| procmail: Match on "xxff"
| procmail: Skipped "c"
| procmail: Assigning "LASTFOLDER=:0"
| procmail: Opening ":0"

The problem is the first recipe inside the block does not have a
corresponding action, so procmail is taking the start of [what you
intended to be] the next recipe as the action. These messages should be
in a file named ":0" in your home directory. Or, unless the log snippet
is munged somehow or some wierd line wrapping occured, there might be a
newline embedded at the beginning of the file name.

At any rate, one way you might do this is something like:

:0
* ^From(_dot_)123247N(_at_)knotes(_dot_)kodak(_dot_)com
* ^Subject:.*test
{
        :0 Bc
        *xxff
        ! bird(_at_)cyber(_dot_)kodak(_dot_)com
        :0 A:
        in-testing
}

Your second (non)recipe in the block has been eliminated and the "c"
flag moved up to the first recipe.  An "A" flag has been added to the
second recipe to say execute this recipe if the condition matched on the
previous recipe (without an "a" or "A" flag at the same nested block
level).  Since there is no condition on this recipe, the action is done
if the previous recipe matched.  The trailing colon ":" tells procmail
to use a lock file while writing to the file in-testing.

-- 
                         /"\
Don Hammond              \ /     ASCII RIBBON CAMPAIGN
Raleigh, NC US            X        AGAINST HTML MAIL,
                         / \      AND NEWS TOO

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail