procmail
[Top] [All Lists]

Re: FW: Truncate an email modify the subject line and then forward the truncated email

2003-06-13 09:42:57
On Fri, Jun 13, 2003 at 04:52:03PM +0530, Vishwas Gite wrote:
I am not able to suitably modify the .procmailrc file so that the
truncated email can be forwarded to an email address.  Help/Suggestion
would be very useful to me.



#Truncate messages longer than 4000 bytes to 100 + 10 lines
:0
* > 1350000
{

:0 fwh
  * ^Content-Length:
  | formail -IContent-Length:

  :0c:${MAILDIR}/test.lock
  ${MAILDIR}/test

:0 fwh
  * ^Subject: *\/[^ ].*
  | formail -I"Subject: --TRUNCATED LARGE MAIL-- Orig-Subj: $MATCH"

  :0c:${MAILDIR}/test.lock
  | /usr/bin/head -100 >> ${MAILDIR}/test

  :0
  /dev/null
}

Well, it's not the height of efficiency to clone the mail only to be
able to send the clone to /dev/null.  You probably don't need to save
the results to a file, either, unless you wnt to archive them locally.
Also, what if the mail doesn't have a Subject:?
Try this:

        MATCH

          :0  # caret, space, and tab are in the brackets below
          * ^Subject:.*\/[^     ].*
          { }

        SUBJ   = "$MATCH"
        PREFIX = "-- TRUNCATED LARGE MAIL --"


        :0
        * > 4000
        | formail -I "Subject: $PREFIX $SUBJ" | head -110 | \
          $SENDMAIL $SENDMAILFLAGS your(_at_)recipient



Or, if you want to cut off the body only, to, say, exactly 100 lines,
if the *body* is longer than 4000 lines:

        :0
        * B ?? > 4000
        {
           :0 bfw
           | head -100

           :0
           | formail -I "Subject: $PREFIX $SUBJ" | \
             $SENDMAIL $SENDMAILFLAGS your(_at_)recipient
        }

-- 
dman

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