procmail recipe example
A typical procmail application is to catch mail messages from certain
people, or certain mailing lists, and drop them in separate folders.
What follows is an edited version of an exchange on the help newsgroup,
where a user was trying to do just that.
For detailed information on
procmail patterns, read the
procmailrc manpage. The manpage
procmailex supplies recipe examples.
Here's the netnews article:
A user asked:
>
> My ~/.procmailrc is now invoked properly, but I'm still seeing
> my messages in my inbox despite trying to file them in another
> folder. I had logging enabled:
> #
> LOGFILE=$MAILDIR/LOG
> LOGABSTRACT=all
> VERBOSE=yes
> but I can't seem to find the log file... Where do I look?
Look a bit higher in your .procmailrc file, and you'll see where MAILDIR
is set to "$HOME/.procmail" -- thus, look at "~/.procmail/LOG". I see
in your subsequent post that you must have done just that, since you
posted an extract from the logfile.
> As for the recipe I'm using, this is the .procmailrc entry:
[...]
> INCLUDERC=persrecip
>
> And this is the recipe (the "persrecip" file) itself:
[...]
> :0
> *^FROMjane
> INPers
>
> INPers is a second incoming mail folder that I've created in alcor which
> *should* get any mail from jane@cs.concordia.ca.
The logfile extract you posted separately shows:
>> procmail: No match on "^FROMjane"
[...]
>> From jane@cs.concordia.ca Sun Mar 9 12:11:25 1997
In other words, your recipe is being used, but the pattern you give
does not match the incoming mail. I think you are hoping that "^FROM"
is a special procmail expression, like "^TO", "^FROM_DAEMON", and
"^FROM_MAILER"; unfortunately, this is not the case. What you meant
is probably:
* ^From:.*jane
However, that would catch mail from "joe@janet.com", which is
^^^^
probably not quite what you want either. Perhaps
* ^From:.*\
would fit the bill.
What it means is:
* Start pattern.
^ Match at beginning of a line; i.e. the next
word or symbol must occur at the start of
the line.
From: Match the word "from" (upper or lowercase
or mixed), followed by a colon. That's the
"From:" header.
.* Match anything (zero or more "wildcard"
characters); this will eat any "comments",
such as the person's full name, etc., and
possibly the space after the "From:", though
the last non-alpha, non-digit character
before the start of the thing you want to
match will be eaten by...
\< Match a "word delimiter" character
(anything except a letter, digit, or
underscore) or a newline -- this avoids
matching on, say, "jbjane@cs...".
jane@cs\.concordia\.ca Match your target address, where dots are
*not* wildcards but match real dots. You
don't *have* to escape the dots, but if you
don't, you might accidentally match
"jane@csxconcordiaxca", which is not what
you want.
\> Now match a word delimiter or a newline
again; this avoids matching the unlikely
"jane@cs.concordia.cam.org", for example.
Also, if you leave the folder name as just the filename without the
path, it will be put in your .procmail directory, which is probably
not what you want. Since you seem to be using the sample procmail
set-up, you probably have PINEDIR set in it. If so, deliver to a file
in $PINEDIR.
Finally, for safety's sake, when delivering to a file you should use file
locking (indicated by the colon after the ":0" beginning-of-recipe
marker). Thus, your recipe would read
:0 :
* ^From:.*\
$PINEDIR/INPers