procmail
[Top] [All Lists]

RE: message size into subject?

2008-03-01 08:56:38
I wrote last night:

Richard KLINDA wrote Thursday, February 28, 2008 1:51 PM:

So my question: is it possible to put a size indicator into the
subject of the message?  I would like to put a "." for every 10
KiB, like:

"Subject: Foo bar baz"

Becomes

"Subject: ....Foo bar baz" if it is more than 40 KiB (and under 50).

Sure, it's possible.  It's not easy, at least all in
procmail (and one formail call to rewrite the Subject).
But here it is.

That worked, but in the light of day I see it is more obtuse
than it needed to be.  Here is an improved version.  As before,
it relies on this rcfile to be used as an INCLUDERC:

 http://vsnag.spamless.us/download/toolkit/func.nndots

Here's today's improved version:

# ------------- Start of 10-KiB-annotation rcfile -------------
  # don't bother if size is under 10KiB
  :0
  * > 9999
  * 1 ^1 > 1
  { SIZE = $=

    _inout = [>999KiB]    # initialized value

    :0
    * $ ^Subject:.*\/[^$WS].*
    { SUBJ = $MATCH }

    :0
    * SIZE ?? ^^.......^^
    * SIZE ?? ^^\/..
    { _inout = $MATCH }

    :0 E
    * SIZE ?? ^^.....^^
    * SIZE ?? ^^\/.
    { _inout = $MATCH }

    :0
    * ! _inout ?? [^0-9]
    { 
       # Change path below to suit
       INCLUDERC = /net/contrib/dman/procmail/tool/func.nndots
    }

    :0 fw
    | formail -I "Subject: ${_inout}$SUBJ"
  }
# -------------- End of 10-KiB-annotation rcfile --------------

____________________________________________________________
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

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