procmail
[Top] [All Lists]

Re: Has anyone written a procmail filter to remove vcards?

1998-05-13 03:11:07
|Tue 98-05-12 Jacques Gauthier <jacques_g(_at_)yahoo(_dot_)com> list.procmail
| # awk script to filter out vcard--
| #anything between begin: to end: wont
| #be printed.

Just for the record: There is general MIME killer recipe that removes
unwanted MIME attachements from the body. Works for vcards, Lotus notes
attachements, html attachements etc...

included in pm-code.shar, see File Server pointer in X-info.
jari


Pm-jamime-kill.rc -- General MIME attachement killer (vcards, html)
@(#) $Id: pm-jamime-kill.rc,v 1.13 1998/05/13 09:40:12 jaalto Exp $

    Description
 
        Microsoft Explorer has a bad habbit of including 7k
        application/ms-tnef attachement to the end of message. The sample
        message is described in next section. If you don't want to see that
        additional ms-tnef attachement, then plug in this module and you no
        longer see MS Explorer cruft.
 
        This recipe works like this: If email's structure is
 
            --boundary
            message-text (maybe quoted-printable)
            --boundary
            some-unwanted-mime-attachement
            --boundary
 
        then the attachement is killed from the body. The message-text part
        is also decoded if it was quoted printable. This leaves clean text;
        with no MIME anywhere. MIME headers have been modified as needed
        (due to conversion from multipart and possibly quoted printable to
        plain text):
 
            message
 
[zap]

    Applications for other mime attachements
 
        Lotus Notes sends similar extra attachement and you can use this
        same recipe to kill it. See example section.
 
        Microsoft Express sends a copy of message in html format in the
        attachement, you can kill that too, see example section.
 
        Netscape's Mozilla sends a copy of message in html. See example.
        Also it sends `vcards'

    Usage example

        If you want to do all by yourself, you can add all this to your
        ~/.procmailrc. This demonstrates the steps to call the includerc.
 
            #   1) Add following line if needed before this script
            #
            #   AWK = "nawk"
            # .....................................................
 
 
            #  2) Next set correct value for attachement killing
            # .....................................................
 
            #   If this is Lotus Notes message, it has extra .pcx attachement
            :0
            * ^X-Lotus-FromDomain:
            {  JA_MIME_TYPE = "application/octet-stream" }
 
            #   If this is MS Express's or Netscape's message with
            #   extra html attachement
            :0
            * ^X-Mailer:.*(Microsoft.*Express|Mozilla)
            {  JA_MIME_TYPE = "text/html" }
 
            #  3) And now handle the message
            # .....................................................
            #    by default kill MS Explorer's ms-tnef attachement.
 
            INCLUDERC = $PMSRC/pm-jamime-kill.rc
 
        But, because all the type detection mentioned above are already
        included in the module, you only need to add conditions that it
        doesn't know by default. This one is exactly the same as above:
 
            :0
            * some-other-attachement-type
            { JA_MIME_TYPE = "some-new-type" }
 
            INCLUDERC = $PMSRC/pm-jamime-kill.rc
 
{...}