• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 343
  • Last Modified:

.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


0
JAPerrett
Asked:
JAPerrett
  • 3
  • 2
  • 2
2 Solutions
 
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
 
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
 
yuzhCommented:
Have a look at the answer in http:Q_20035506.html
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now