Stripmime

Overview

Stripmime is a perl script which is designed for use with mailing list systems. The goal of the program is to take email which has MIME formatting and to break it down into simple text email. This prevents HTML formatting from messing up your digests, or attachments from being sent to the list at all.

Getting It

Stripmime is a simple Perl script which fits into one file. You can get it here. Stripmime may be freely distributed but the code is Copyright Alex Wetmore.

Installing it

Stripmime is installed in your /etc/aliases file before the script that handles your mailing list. Here is a sample from one of my lists:

touring: "|/usr/local/bin/stripmime.pl|/usr/local/mailman/mail/wrapper post touring"

No Perl modules are used. The script should run on any system with Perl5. If your perl interpreter isn't located at /usr/bin/perl then the first line of the script might need to be changed.

How it works

The stripmime is implemented as a simple filter. It reads the incoming message one line at a time, and decides if it should keep or discard that line, based on the current body section. If there is only one section, and that section is HTML formatted, then it will remove the HTML tags and leave behind plaintext. It also attempts to clean up quoted-printable text and turn it back into regular plaintext. If the message is formatted as a MIME message with a multipart/alternative of text/plain and text/html (this is how most rich text email is sent) then stripmime only keeps the text/plain section.

The advantage of this system is that the script has very minor memory requirements (it rarely buffers more than a couple of lines of text at a time) and it never needs to make temporary files. The disadvantage is that the HTML parser is very rudimentary compared to other systems which use lynx or similar tools to render the HTML.

If the message doesn't contain a text/plain section (or a top-level text/html section) then stripmime throws out everything and appends a warning message explaining what happened. It also prints a message when it removes or alters any section so that the user knows what is going on.

Change History

Todo list

Links

alex@phred.org