procmail
[Top] [All Lists]

Re: Conditional to From: being an email address in a file

2009-10-12 14:55:47
At 04:47 2009-10-13 +1300, reti(_at_)igrin(_dot_)co(_dot_)nz wrote:
I simply wish to check as a From: condition, that the email address is one
of many contained in the file emaillist.txt, and if so, I send it onward
via addresses in another file outgoinglist.txt

This is such a common extraction, the first recipe is pulled directly from the sandbox that I publish. Everything else could drop right into a filter.rc test filter, and you can test it to your heart's content without actually sending real messages out to sendmail for delivery.


# get the From: address as an address component ONLY (no comments)
:0 h
CLEANFROM=|formail -IReply-To: -rtzxTo:

# now, just grep for it (yes, this could be the condition line in the recipe,
# but breaking it out separate allows you to SET a variable with the matched
# address)
SKIPPER=`grep -x -i "$CLEANFROM" /some_path/emaillist.txt`

# If $SKIPPER is non-empty, we matched something
:0
* ! SKIPPER ?? ^^^^
| formail -I "To: `cat /some_path/outgoinglist.txt`" | $SENDMAIL -t


Be wary of forwarding mail in this fashion if you haven't checked to make sure it's not forged -- you could easily relay a lot of spew.


---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

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