Ahh... yess.... This gives me flashbacks to when I worked for a major financial company just prior to Y2K. I was given the assignment to write a script similar to what you are describing. This was part of the paranoia that existed around Y2K in that management was concerned that viruses contained within binary attachments would infiltrate the network and wanted attachements "jailed" until January 5, 2000 after being virus inspected. I named the script "mailStripper" and collaborating with my bretheren in the messaging group we put the script on two machines named "chip" and "dale". I announced this in a meeting with senior VPs with an absolute straight face by my manager at the time absolutely lost it. (I didn't warn him!)

Anyway enough of the war story! This is certainly a case of TIMTOWTDI! I echo what Brother Roger says in suggesting that you look at Mail::Message::Attachment::Stripper but also look at the whole family of MIME:: modules on CPAN. Psuedocode for how my script worked looked like:

Open the message. Does it have attachments? Yes: Inspect each attachment is it one of the allowed types? Yes: leave attachment intact No: Strip the attachment replace it with a note to the end user that it has been stripped and jailed. No: send message on without being molested.

Unfortunately I didn't keep a copy of the script around so I can't post it here.


Peter L. Berghold -- Unix Professional
Peter at Berghold dot Net
   Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.

In reply to Re: Remove Email Attachments by blue_cowdawg
in thread Remove Email Attachments by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.