> From: Bryan Hoover > Sent: Saturday, January 03, 2004 2:46 AM > [...] > Bob Proulx wrote: > > > > Bryan Hoover wrote: > > > HEADERTAG=From > > > ADDRESSFILE=/usr/home/bhoover/listreply > > > > Use $MAILDIR here? > > > > ADDRESSFILE=$MAILDIR/listreply
If you use $MAILDIR, there is no reason to fully qualify the delivery folder name. Procmail will do that for you. So, the following will do: ADDRESSFILE=listreply > > > > :0i > > > HEADERTAGVAL=|$FORMAIL -zx$HEADERTAG | tr -d "\n" | tr -s " " As a matter of procmail style, using backticks, not inside a delivery recipe is simpler: HEADERTAGVAL=`$FORMAIL -czx$HEADERTAG` Adding the '-c' switch above makes formail continue the header lines, thus removing newlines and unnecessary white space in the continuation lines. > > > > > > * ? grep -i $HEADERTAGVAL $ADDRESSFILE > > > > I like it! Much more efficient than listing all of the addresses > > out. > > Right, if you're just matching on From:, then no problem. But for say, > the To: macro, you'll potentially get more than one address. So you'd > need a way to feed to grep one at a time. The recipe I have in use > turns things around, looks for each address in $ADDRESSFILE as a > substring in $HEADERTAGVAL. > Seems like a lot of potential for false positives. > > But there is some room for false hits. Wouldn't the -x option to grep > > be appropriate there? And it probably should be quiet too. And > > probably you don't want to use regular expressions (but maybe you do). > > Using the substring matching as mentioned, I've not seen any false hits > in the 1.5 years I've been doing it that way. > Have you always been using "From " (envelope sender) or From: as the header tag? Here is a simpler way to get only the address part of the sender's address: FROM=`formail -rzxTo:` # envelope (or From_) sender REALLY_FROM=`formail -rztxTo:` # From: sender Both of these formail invocations will return only the address part of the field, so no further parsing is necessary. There is no such simple solution for To: and Cc: fields however. > About the quiet parameter -- maybe Procmail ignores failed match > output. Yup, but why generate output when you don't need it? > > Otherwise, the objective might be then, to break up each address out of > the given header, before greping -- which could make for some pretty > "nasty" parsing. I'm pretty sure of this, because I googled up the > following part of a thread from which can be downloaded Phillip > Guenther's recipe files for doing it: > > http://info.ccone.at/INFO/Mail-Archives/procmail/Nov-2002/msg00140.html > > See the files prefaced with 822, starting with 822mailbox-list. > > Again, my quick and dirty was to simply grep each line -- extracting > with sed -- from $ADDRESSFILE, and grep for its substring in the header > field -- much, much easier, though not perfect. Do you really get a lot of additional mileage out of grepping the To: and Cc: lines? Wouldn't the sender From_ or From: addresses do? ------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ Spamassassin-talk mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/spamassassin-talk