JoeL wrote Friday, October 03, 2008 8:45 PM:
Ok, sorry for that, i dont know why i didn't put the complete
procmailrc file the first time, it looks like this:
And now we see the recipes but no longer have in front of us
a description of what your problem was. [Rant I wrote now
deleted; I found your explanation way down at the bottom.
I will quote it here now instead of leaving it way far down
where it is hard to notice.]
[Okay, what I originally wrote here, that now should be
considered deleted, was: "I certainly didn't
save your earlier message, and I'm certainly not going to
bother going to the list archives to dig up what your question
was. I vaguely remember that you thought something should
deliver that wasn't."] :-)
These are the 4 recipes, what i'm tryng to do is:
If an email matches recipe 1 or 2, then finish there, if it
doesn't match 1 o 2, then do 3 and 4.
[Nevertheless, # delete that word now :-) ] I will look through
your code and make a couple of remarks. [Maybe I'll even find
the thing you're asking about, without knowing right this second
what that was, again. # Also to be deleted. :-)]
LOGFILE=/var/log/provision/procmail.log
FORMAIL=/usr/bin/formail
Personally, I'd just trust the path to find /usr/bin and
not bother making this into a var. But whatever.
SENDMAIL=/usr/sbin/sendmail
Should be the compiled-in value. SENDMAIL is one of the
few env vars (maybe the only one?) that gets set to a binary
automatically by procmail.
:0
* ^Subject:.*Mensaje SGOBA
*
^To:.*(testbucle(_at_)lotus[(_dot_)]domain[(_dot_)]com|testbucle(_at_)es[(_dot_)]domain[(_dot_)]com)
I'd write it something like:
^To:(.*\<)?testbucle@(lotus|es)[.]domain[.]com
Aside from the regex compression I did, also note that you did not
anchor the left of your expression. So while "testbucle@"-whatever
will certainly match, so will, e.g.,
"supercalifragilistictestbucle@"-whatever.
Sure, it's unlikely with your address, but it's still a bad habit.
With my email address, if I just match on ".*dman@", I will also
get undesired matches on stuff like "feldman@".
The "(.*\<)?" helps a lot and I would call it rigorous "enough,"
though it still could be fooled. E.g., again using "dman@",
well, this -- "^To:(.*\<)?dman@" -- while it no longer would
match on "feldman@", would still match on "tom.dman@". As I
said, though, probably good enough. There is ultimately a trade-off
between rigor and being so anal as never being able to get anything
done, and I personally think the "(.*\<)?" reaches that line well
enough.
:0 c
| $FORMAIL -A "X-Processed: yes" | \
$SENDMAIL -oi testbucle(_at_)domain(_dot_)com
You do realize that the c-flag clones the message, so you'll
still have it below, right? If you wanted to deliver it at
this point, get rid of the c-flag.
:0
* ^Message-ID:.*<\/[^(_at_)]+
The ".*<" will catch all properly-formed Message-IDs, but miss
illegally-formed ones. A fair number of spam comes with malformed
Message-IDs. So while you might like that you're not processing
spam, it also might not be what you wanted or expected.
{ MESSAGEID = $MATCH }
:0 E
{ MESSAGEID='none' }
Or "malformed."
DUMMY = `mkdir /emails/testbucle/"$MESSAGEID"`
:0 fwi
| ripmime -i - -d
/emails/testbucle/$MESSAGEID --syslog --no-nameless ; \
$RENAME /emails/testbucle/$MESSAGEID $MESSAGEID 1
I suspect here is where you ought to have, instead, flags:
:0 cwi
And now that I found your description of what you wanted to do
(and moved it up-top), I can say that if you want to have stopped
here on success, get rid of the "c" flag and get rid of your
"f" flag that I had suggested changing to a "c" flag. :-)
:0
* ^Subject:.*(Inicio de
=?iso-8859-2?Q?tramitaci=F3n_de_solicitudes_para_036?=)
*
^To:.*(preselec(_at_)lotus[(_dot_)]domain[(_dot_)]com|preselec(_at_)es[(_dot_)]domain[(_dot_)]com)
So -- if we're still here processing, then something went awry?
Methinks you should make this an E- or e-flagged recipe. But
anyway, you won't need to if you remove the f/c flag above on
the last recipe.
In any case, if you're going to re-use the To: rgex, well,
turn it into a var up above. Then use it like so:
* $ ^To:(.*\<)?$LOTUSorES
{
:0 c
| $FORMAIL -A "X-Processed: yes" | \
$SENDMAIL -oi gpg(_at_)domain(_dot_)com
"$SENDMAIL" $SENDMAILFLAGS gpg(_at_)domain(_dot_)com
$SENDMAIL could have whitespace in it, is why the quotes. E.g.,
on Windows machines that call compiled Unix-like binaries.
Don't quote $SENDMAILFLAGS, though.
:0 c
| $FORMAIL -A "X-Processed: yes" | \
$SENDMAIL -oi preselec(_at_)domain(_dot_)com
I have no idea why you are cloning the message to add another sender.
Just put them both on the first sendmail line.
"$SENDMAIL" $SENDMAILFLAGS
gpg(_at_)domain(_dot_)com,preselec(_at_)domain(_dot_)com
By the way, "domain.com" is an actual place, with a few hundred thousand
customers, so I don't actually approve of using that name in examples.
Use "example.com" for examples. That's what it's there for.
:0
* ^Message-ID:.*<\/[^(_at_)]+
{ MESSAGEID = $MATCH }
Uh, we already got the Message-ID up above. There is no reason to
do it again.
:0 E
{ MESSAGEID='none' }
DUMMY = `mkdir /emails/preselec/"$MESSAGEID"`
:0 fwi
| ripmime -i - -d /emails/preselec/$MESSAGEID
--syslog --no-nameless ; \
$RENAME /emails/preselec/$MESSAGEID $MESSAGEID 2
DUMMY = `rmdir /emails/preselec/"$MESSAGEID"`
Why are you repeating all this stuff?
}
:0c
* ^Subject:
* ^From:
* ^To:
{
:0
{
MESSAGEID2=`${FORMAIL} -cX "Message-ID:"
You already GOT the MessageID. Sheesh!
|sed -e 's/[ \t]\{1,\}//g'`
SUBJECT=`${FORMAIL} -cX "Subject:"`
FROM=`${FORMAIL} -cX "From:"`
TO=`${FORMAIL} -cX "To:"`
DATE=`${FORMAIL} -cX "Date:"`
ADDR=`${FORMAIL} -cX "Received: from"`
This ought to work but is entirely wasteful. Just use procmail
to grab these things.
SPACE = ' '
TAB = ' ' # a real one
WS = $SPACE$TAB
:0
* $^Subject:.*\/[^$WS]+
{ } SUBJECT = ${MATCH:-none}
And repeat that for the others. you can put it all in a sub-rc that
you call with INCLUDERC.
You can also get rid of tabs with procmail-only, but I won't bother
going into that here. At the very least, you should test for a
tab in procmail before bothering to call sed for each message. Only
call it where needed.
:0 # not a delivering recipe
* $ ^\/someheader:.*$TAB.*
TABLESS_HEADER=| ( echo "$MATCH" | sed "/s/$TAB//g" ) # or whatever
}
:0i
| echo -e
"$DATE\n$MESSAGEID2\n$SUBJECT\n$FROM\n$TO\n$ADDR\n" >>
/var/log/provision/reenvios.log
This would work but is unnecessary as a shell call.
LOGFILE = /path/to/reenvious.log
LOG = "$DATE
$MESSAGEID2
$SUBJECT
$FROM
$TO
$ADDR
"
(Or set, up above:
NL = '
'
and use $NL in the expression.
:0w:
| /home/vpopmail/bin/vdelivermail ''
/home/vpopmail/domains/es.domain.com/backup
Might be better to put the emergency backup way up at the top
of the rcfile.
dman
____________________________________________________________
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