procmail
[Top] [All Lists]

Re: How do I filter messages > size into a folder

1997-08-08 02:17:00
On Fri, 8 Aug 1997 03:25:39 -0400 (EDT),
"Mike A. Harris" <mharris(_at_)blackwidow(_dot_)saultc(_dot_)on(_dot_)ca> wrote:
I'm wanting to do the following:
1) Filter any messages bigger than 100k into the folder BIGMAIL
2) Have a message sent to my normal inbox saying the following:

This is completely off the top of my head but hopefully it should at
least be enough to get you started. 

:0
* > 102400
{
    # Save a copy of the original (perhaps in /tmp or somewhere?)
    :0c:
    BIGMAIL

    NL="
"

    # Generate a warning in $DEFAULT
    :0h:
    | formail -XFrom -XSubject: -XAttachment: | \
        sed -e "1a\\${NL}From: mharris\\${NL}To: mharris\\\
${NL}Subject: ATTN: Big One\\$NL\\${NL}Here's a big message:\\$NL\\$NL" \
            -e '1!s/^/    /'   >>$DEFAULT
}

This will grab the From_ line in the original message, insert some new
headers, and move the rest of the extracted header lines into the body
of the generated warning message. Your mail program might also want a
Date: header on the warning message -- you can probably grab the one
from the original here as well, or grab it from the From_ line. (This
will complicate the script further. 
  Another option might be to use the date(1) program to generate the
new header, and put all the formail-extracted stuff in the body. If
your mail client is picky about what kinds of From_ lines it will
accept, this can be hard; the following should give you an idea of
what might work, but no guarantees:

    :0h:
    | date +'From mharris  %c%nFrom: mharris%nTo: mharris%nSubject: ATTN%n' ; \
        echo "Here's a big message we received, gollum gollum:" ; echo ; \
        formail -XFrom: -XSubject: -XAttachment:     >>$DEFAULT

A simpler alternative might be to generate a headers-only warning
message with the original Subject: in Old-Subject and the original
From: line etc -- man formail has the scoop on that.

This is untested and might contain a glitch or two. Shake well before
use. Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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