.procmailrc recipe

here is the basis for what I want as a procmail recipe

FGREP=/usr/bin/fgrep
FROM='formail -x From:'

:0
* ^X-Sender-Verify:.*could not be verified
!* ? (echo "$FROM" | $FGREP -i -f $HOME/ok
 !junkmail

(taken from http://handsonhowto.com - thank you very much btw - got me most of the way to what I want)
what I want to do is junk any emails with the 'could not be verified' string in header if not in the ok file. I want to be able to enter generic addresses such as *@easyjet.com

will the above recipe work and continue to process other recipes for such an email.


If I have this request in the wrong section , let me know - it's the nearest I could find - thanks


JAPerrettAsked:
Who is Participating?
 
ITcrowCommented:
FGREP="/usr/bin/fgrep"
FGREP_OPTIONS="-i -s -f"
OKFILE=$HOME/ok
BANFILE=$HOME/banned

# What do we do for banned senders.
:0ch
* ? (formail -xFrom:) | $FGREP $FGREP_OPTIONS $BANFILE
.... Do something here ....

# What do we do for un-verified senders.
:0ch
* ^X-Sender-Verify:.*could not be verified
* ! ? (formail -xFrom:) | $FGREP $FGREP_OPTIONS $OKFILE
.... Do something here ....


You can even combine the two. fgrep has '-v' which returns back stuff that is not matched.
But, in the receipe you have "* !" which means receipe is accepted if the condition fails.
0
 
JAPerrettAuthor Commented:
been trying at command line with grep, egrep, fgrep, but test seems to be opposite way round to what I want
with file ok containing
@easyjet.com

 when I type fgrep -i "jet.com" ok
it echos the line @easyjet.com , cos jet.com is in @easyjet.com
what I want is the reverse check where I check for the existanse of the line in the file within my pattern entry. is there such a command?
0
 
yuzhCommented:
Have a look at the answer in http:Q_20035506.html
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
JAPerrettAuthor Commented:
the concept i have is

* ^X-Sender-Verify:.*could not be verified
if the heading X-Sender-Verify indicates that the email cannot be verified
!* ? (echo "$FROM" | $FGREP -i -f $HOME/ok
and the sender is not in the accepted list
 !junkmail
dump it to junkmail

otherwise accept and process as normal - sending it to the desired recipient with a later recipe

hence the !
and I'm ok with that, (or at least It seems logical to me)


the problem I am trying to resolve, is that if my $HOME/ok file conains exact matches, then it will work,
but what I want is to find a match with fgrep/another program
that will match newsletter@easyjet.com in $FROM with *@easyjet.com in the ok file, and this is the bit I am struggling with



0
 
ITcrowCommented:
Try something similar to:

FROM='formail -x From:'|/bin/cut -f1 -d'@'
FROM=@$FROM

0
 
yuzhCommented:
Should be:

FROM='formail -x From:'|/bin/cut -f2 -d'@' # you get easyjet.com
FROM="@${FROM}"  # make @easyjet.com
0
 
JAPerrettAuthor Commented:
Sorry I left it so long - other things got a higher priority - plus been away a bit. - Thanks for the feedback everyone.. I have read the answers now, and sorry I left it to admin to clear up the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.