stripmail − a utility to strip unwanted MIME parts from inbound e−mails.
stripmail [ -v ] [ -t | -h ] [ −p prologue_file [ -P prologue_character_set ] ] [ −e epilogue_file [ −E epilogue_character_set ] ] [ −s size[k|K|m|M] ]
This software and the man page accompanying it are supplied as is, with no expressed or implied guarantee of suitability, and are released under the GNU General Public License Version 2 (or later, at your convenience) as published by the Free Software Foundation.
Details of the GNU General Public License are available from the Free Software Foundation’s website at this URL:
stripmail makes use of the regular expression pattern matching functions included in libpcre and the character set conversion functions in libiconv.
The purpose of stripmail is to remove unwanted portions from an e-mail message. Such unwanted portions may be HTML content, Windows executable files or any other kind of content you may decide you don’t want to receive.
stripmail takes its input, the original mail, from stdin and sends the processed mail out on stdout, which makes it very simple to use stripmail as a procmail(1) filter.
stripmail breaks the inbound mail down into its individual MIME parts. Each MIME part’s Content−Type: header is checked first of all. If the −t option was used then only MIME parts of which the content is text/plain will be allowed through. If the −h option was used then text/html MIME parts as well as text/plain will be allowed through.
If neither the −t nor the −h options were used then the Content−Type: header is checked against a list of regular expressions in the stripmail.mimeallowed configuration file. If it matches one of the regular expressions then a preliminary green light is given. If not, then a preliminary red light is given.
If the MIME part was initially allowed then we perform a further check in order to ensure that nothing unwanted gets through. The headers are further examined in order to find a filename for an attachment stored in this MIME part. If one is found then it is checked against a list of regular expressions in the stripmail.namedenied configuration file, and the preliminary authorisation initially granted is revoked if a match is found.
If, on the other hand, the MIME part was not initially allowed, we also look for an attachment filename and, if one is found, check it against a list of regular expressions in the stripmail.nameallowed configuration file. If it matches one of these regular expressions then the authorisation initially denied is granted.
Finally, if the −s option was used, we check the size of the MIME part’s body, but only if this MIME part is not, itself, a multipart section. If it is a multipart section, then each of its individual MIME parts are examined. If the MIME part’s size is greater than the maximum size specified then it is not allowed through.
MIME parts that are not allowed through are replaced with text/plain sections explaining that a MIME part has been stripped, giving the original MIME part’s content type and, if applicable, the filename and a note saying that the part was stripped because it was too big.
Optionally, a prologue can be prepended to the mail and/or an epilogue appended. This additional part must be plain text in a file and terminated with a ’\n’. Also, if the text content is anything other than plain, 7-bit ASCII, stripmail must be informed of the character set used. If any character set conversions and/or MIME encapsulations are required in order to make the mail’s character set and those of the prologue and epilogue match, stripmail will take care of it automatically.
In the event of stripmail not being able to process the inbound mail, it will be passed through unfiltered in any way unless the error occurs during the process of reading in the original mail, in which case stripmail will exit with a non-zero exit code.
Each of the three configuration files used by stripmail: stripmail.mimeallowed, stripmail.namedenied and stripmail.nameallowed, is searched for initially in the $HOME/.stripmail directory of the user invoking stripmail, then in /usr/local/etc, and finally in /etc
Prints version information and exits.
Strip all MIME parts except text/plain.
Strip all MIME parts except text/plain and text/html.
Prepend the text in the file prologue_file to the mail once processed. If the text in this file contains 8-bit or multibyte characters then use the −P option too (see below).
Inform stripmail that the text in prologue_file uses the given character set.
Append the text in the file epilogue_file to the mail once processed. If the text in this file contains 8-bit or multibyte characters then use the −E option too (see below).
Inform stripmail that the text in epilogue_file uses the given character set.
If the data size of any non-multipart MIME section exceeds size bytes (or kilo- or megabytes if a k, K, m, or M suffix is used with no space between size and the suffix) then strip it from the mail. size must be an integer and can be given in decimal, hexadecimal or octal. For example: -s22528, -s22k, -s0x5800 and -s054000 will all have the same effect.
procmail(1), pcre(3), iconv(1), iconv(3), RFC-2822, RFC-2049
None known as yet but of course I’d like to receive bug reports. Send them to gstewart(at)spamcop(dot)net.
stripmail and this man page were written by Godwin STEWART, gstewart(at)spamcop(dot)net.
stripmail’s homepage is http://linux.sgms-centre.com/misc/stripmail
Powered by Apache / Slackware Linux
Last update: 05-JAN-2006 15:14:27 UTC