reti | 12 Oct 2009 17:47
Picon

Conditional to From: being an email address in a file

A simple problem but one that alludes my exploration of the man files and
archives. Grateful for the usual excellent advice I get from this list.

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

:0
*^From: [emaillist.txt]
 | formail -I "To: `cat /home/outgoinglist.txt`" | $SENDMAIL -t

Thanks again.

Shane
Ruud H.G. van Tol | 12 Oct 2009 20:36
Picon

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

reti <at> igrin.co.nz wrote:

> I simply wish to check as a From: condition, that the email address

The first one, or (potentially) all of them?
Check also the one in the "From " postmark header line.

--

-- 
Ruud

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

At 04:47 2009-10-13 +1300, reti <at> igrin.co.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

(Continue reading)


Gmane