[PROCMAIL][LONG] Allowing multiple lines for one recipe
am 24.04.2005 11:23:43 von Thick blokeProcmail version = v3.22 2001/09/10
O/S = Fedora Core 3
Editor = vim
Hello all,
I have a working procmailrc which contains a recipe which I would like to
expand upon, preferrably to two or three lines for the same condition.
It is a personal project of mine, which was started simply to help me learn
a bit more about procmailrc.
What I'm working on is a basic profanity filter. It searches the body of
every email for specific words, and if a match is obtained, formail adds an
'X-Profanity: Yes' header line. A following recipe looks for this particular
header, and if found it tells formail to prepend [PROFANITY] to the subject
line of the mail in question. This is probably not the best way to do it,
but it's working, albeit with one main problem discussed further on.
My reasoning for using a body match rather than a header (e.g Subject:)
match is that it would be rather obvious if profane words were in the
subject line as I would immediately see them upon firing up my MUA. I use
Pine so I don't know if there's any naughty stuff written in the actual
message until I open it, as it has no preview window thankfully.
Here are the relevant parts of my procmailrc as far as I know. (Profane words
modified to avoid offence) :
#!/bin/sh
SUBJECT=`formail -xSubject:`
# Additional custom header written if *any* message body arguments match.
# Using '|' to mean 'OR'.
:0f
* B ?? .*\
|\
| /usr/bin/formail -A "X-Profanity: Yes"
# Prepend '[PROFANITY]' to subject line if above filter matches.
:0f
* ^X-Profanity: Yes
| /usr/bin/formail -I Subject:"[PROFANITY]$SUBJECT"
I realise my matching expressions are rubbish, and could be made more
efficient by better use of regexps. I just wanted to get something up and
running with two or three lines of words to match, and then start to
fine-tune the procmailrc as I learn more about regexp's as far as procmail
is concerned. Therein lies the heart of my question to you all.
You will notice the '\\' at the end of the condition line. I am trying to
make procmail carry on to the next line '|\
line. I've done something wrong as the test word 'pop' never seems to be
used. I've been searching for the right character to signify 'newline'.
Sorry for sounding so thick, but is this simply a press of the 'Return' key
? I feel a bit like someone asking "Where is the 'any-key' ?"
I just don't know what to add, as all my variations have failed.
I did find this very helpful page during my searches :
http://www.ii.com/internet/robots/procmail/qs/
Most of my other searches referenced 'non-newline', and not 'this is a
newline character, right here noob !'. (My Google skills could do with a
refresher course I guess.)
I admit I am rushing through it, simply trying to find a way to have two or
more lines for the same condition. How do I do that ? Is it '\\' ? Sorry
but I don't understand the meaning of the '/n[y]oo'li:n' part of the
definition of newline, here :
http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?newline
When I press CTL and J, I don't get any characters at all in my procmailrc.
I know I'm sounding like a prat, but I've just got to get this working, it's
driving me mad.
Thanks for your time all.
TB.