procmail
[Top] [All Lists]

Re: Restricting mail size to under 10K

1998-02-26 12:45:00
Sean Straw suggested to Daryl Chang (as a second recourse in case the goal
can't be accomplished by the MTA),

| To achieve this in procmail, the following would probably work (NOT TESTED
| - that's up to you to do):
| 
| :0
| * > 10240
| * !^FROM_DAEMON
| * !^From:.*YOUR-ADDRESS
| * !^X-Loop:[  ]*YOUR-UNIQUE-LOOP-IDENTIFIER-HERE
| | ( formail -rk -A "Precedence: junk" \
| -A "X-Loop: YOUR-UNIQUE-LOOP-IDENTIFIER" \
| | $MYBIN/insertdoc -v file=$AUTOREPLY/msgtoolarge ) | $SENDMAIL -t -oi -oe
| 
| the insertdoc script:
| #! /usr/bin/gawk -f
| /^[ \t]*$/ && !INSERTED { print; system("cat " file ); INSERTED=1}
| 1

I don't see the need for the script (and its calls to gawk and cat).  If you
want to put $AUTOREPLY/msgtoolarge at the top of the body, you can use an
intermediate filtering recipe that just calls cat, or you can do it in the
same pipeline with sed instead of a gawk script (and you don't need the
parentheses).

  :0
  * > 10240
  * !^FROM_DAEMON
  * !^From:.*YOUR-ADDRESS
  * !^X-Loop:[  ]*YOUR-UNIQUE-LOOP-IDENTIFIER-HERE
  | formail -rk -A "Precedence: junk" \
   -A "X-Loop: YOUR-UNIQUE-LOOP-IDENTIFIER" |\
   sed -e '1,/^$/!d' -e "/^$/r $AUTOREPLY/msgtoolarge" | $SENDMAIL -t -oi -oe

Alternatively, we could use a filter first and cat instead of sed:

  :0fh # formail's -k option is dispensable but harmless here.
  * > 10240
  * !^FROM_DAEMON
  * !^From:.*YOUR-ADDRESS
  * !^X-Loop:[  ]*YOUR-UNIQUE-LOOP-IDENTIFIER-HERE
  | formail -rk -A "Precedence: junk" \
   -A "X-Loop: YOUR-UNIQUE-LOOP-IDENTIFIER" ; cat $AUTOREPLY/msgtoolarge
   
   :0A
   ! -t -oi -oe

| This is easier if you don't need to send back the original body.

Yup.

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