procmail
[Top] [All Lists]

Re: filtering attachments

2002-01-24 09:42:49
Carlos asked,

| The recipe below works ALMOST as expected. If the message is rejected, the
| sender receives the reply but the message is not trashed, I mean, the
| message is also delivered to its destinatary.

I'll get to that farther below, but let's get your second question out of
the way first:

| I would like to have the recipe also reordered. If the sender is on the
| ok_list it should not be necessary to go through the recipe but don't know
| how to use the else options (:0 e).

`e' is for error; `E' is for else.  I don't see either of them in the code
you posted, so I can't address that.  But just put the `!? formail | fgrep'
condition first (and put `H ??' on it to override the `B' from the colon
line); once an unweighted condition fails, the rest of the recipe is
skipped.

| ok_list=/home/test/ok_list
| ws = '[  ]*($[   ]+)*'
| dq = '"'
| ext = '(a(d[ep]|r[cj]|s[dmxp]|u|vi)|\
|        ... deleted ...
|        z(ip|oo))'
| :0 B
| * -3^0
| * 4^0 $ name${ws}=${ws}${dq}.*\.${ext}(\..*)?${dq}${ws}$
|         ... deleted ...
| * 2^0 \<(app|bgsound|div|embed|form|i?l(ayer|ink)|img|\
|          i?frame(set)?|meta|object|s(cript|tyle))
| * 2^0 =3d
| * !? formail -rtzxTo: | fgrep -i -f $ok_list
|
| {
|     :0
|     | (formail -r -I"Subject: Message rejected" \
|        -A"X-Loop: test(_at_)fda(_dot_)com(_dot_)br" ; \
|     echo "Please Contact suport(_at_)fda(_dot_)com(_dot_)br") \
|     | /usr/lib/sendmail -t
| }

First, there's reason to open braces for a single unconditional recipe.
(For an assignment, yes.)  Second, my first guess is that the problem occurs
only on longer messages and not on the very shortest ones, because procmail
is trying to write the entire message to a command that reads only the head
and refuses to read the body (formail -r without -k), so procmail is
reporting a write error in your logfile.  When the unread body is long
enough for procmail to have to start another buffer, procmail will notice a
write error, deem the recipe a failure (even though the action ran), and
consider the message undelivered, so it will keep reading more recipes, or
if that's the end of the rcfile procmail will deliver to $DEFAULT.  If my
guess is right, you need the `h' flag so that procmail will try to feed only
the head to the pipe.

Also, I don't see anywhere ... maybe you're doing it somewhere else in the
code ... that you check for your own X-Loop: line.  An loop detector works
only if you both add it and look for it.

Suggestion:

 :0 Bh
 * ! H ?? ^X-Loop: test(_at_)fda\(_dot_)com\(_dot_)br
 * ! H ?? ? formail -rtzxTo: | fgrep -i -f $ok_list
 * -3^0
 * 4^0 $ name${ws}=${ws}${dq}.*\.${ext}(\..*)?${dq}${ws}$
         ... deleted ...
 * 2^0 \<(app|bgsound|div|embed|form|i?l(ayer|ink)|img|\
          i?frame(set)?|meta|object|s(cript|tyle))
 * 2^0 =3d
 | (formail -r -I"Subject: Message rejected" \
      -A"X-Loop: test(_at_)fda(_dot_)com(_dot_)br" ; \
   echo "Please Contact suport(_at_)fda(_dot_)com(_dot_)br") \
   | /usr/lib/sendmail -t




_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>