Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: limiting mail size that is receivable and deleting it from my mail server (fwd)



On Sat, Dec 19, 1998 at 04:05:54AM +0000, nivad wrote:

> I have been working on a problem that is somewhat related to Eric's.
> Transferring email into my palm III... only allows mail up to 8K so I am
> unable to load in the daily news from CNN since it is usually over 10K.
> As a solution, I want to split the mail up into smaller chunks for which I
> thought procmail would be the answer.  So far I have been unable to get
> procmail to do this.

Procmail itself won't do that, but you should be able to manage it with an
external filter -- I've used sed as critical element of a complex
splitter with good results, so (with a view to keeping the overhead
low) I would have have a think about whether counting lines (which
is as close as sed will take you to measuring file size on the fly)
will be enough precision for your needs.

You'll need a filter that recurses, in order to handle arbitrary file
sizes.  Procmail can't recurse internally; you need to invoke it by tail
recursion of the entire Procmail process.  On each recursion, you just
deliver the top of the message, and recurse if there's anything left after
you cut that bit out of a copy of the same message body.  You can't pass
shell variables between interations of Procmail, because they exist in
different subshells.  So to control iteration, you need to perform some
fancy footwork in the headers, inserting data, snatching it to a variable,
then deleting the header before delivery.

It will look SOMETHING like this (this is just a doodled outline):

# file: procmail.chop
#
# Set the number of lines we'll consider for immediate delivery
LASTLINE=600
COUNT=0

# If this is not the first pass, doctor the message id so that
# this won't look like a duplicate; use a counter incremented
# on each pass for this purpose.  Also wipe the signalling header.
:0 fw
* ^x-start-end: \/.*
{ COUNT=`echo $MATCH 1+p | dc`
  :0 w
  * ^message-id: \/.*
  { MESSID=$MATCH
    NEWMESSID=`echo $MATCH|sed -e s/...$COUNT.../.../`
  :0 fw
  | formail -I X-Start-End: -I Message-ID: -A Message-ID: $NEWMESSID
}

# Make a copy of the message, and cut everything 
# below the end, and deliver the "window".
:0 cw
{ :0 fbw
  | sed -e ... -e ... -e ...
  :0:
  ! my_account
}

# On the copy, cut everything down to the end of the
# window (it's just been delivered, so we don't need it anymore).
:0 w
{ :0 fbw
  | sed -e ... -e ...
  :0:
  ! my_account
}

# Now just iterate.  We don't filter, because we want the
# current instance of procmail to exit.
:0 w
| formail -I Message-ID: -A \"Message-ID: $MESSID\" procmail -m \
  procmail.chop

# Hmm. We'll need to make the existence of SOMETHING in the
# body a condition of performing the above recipes.  If
# procmail doesn't do this implicitly, we may need to 
# impose the condition above, and unconditionally deliver
# the exhausted message to /dev/null if this is an empty
# message.
:0 
/dev/null

Good luck!

> BTW, I believe this to be a solution for Eric by using procmail
> with the following filter to pass email over 1.5M to the bit bucket.
> Right?
> 
> :0
> * > 15000000
> /dev/null 

Looks right.

Cheers,
-- 
-x80
Frank G Bennett, Jr         @@
Faculty of Law, Nagoya Univ () email: bennett@example.com
Tel: +81[(0)52]789-2239     () WWW:   http://rumple.soas.ac.uk/~bennett/

-------------------------------------------------------------------
Next Nomikai: 14 January 1999, 19:30 Tengu TokyoEkiMae 03-3275-3691
*** it will will be Jan 14 (Thu), as Jan 15 (Fri) is a natl holiday
Next Technical Meeting: 13 February, 12:30               Place: TBD
-------------------------------------------------------------------
more info: http://tlug.linux.or.jp                     Sponsor: PHT


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links