normail - normalizing mime encoded mail


NAME

normail - normalizing mime encoded mail


SYNOPSIS

  normail [options] [filename]

filename should point to a file that contains one single mail. If filename is omitted and STDIN is not a terminal STDIN is used instead.

Other names of this file could be norfilter (see Normalization), norver (see Verification) or norcheck (verify silently) that implement different sets of default options.

Give options -hh or -hhh for more information.


OPTIONS

Options are normally starting with -- and may be abreviated as long as they are unique. Run normail -vv </dev/null >/dev/null to see the default settings of all options.

--help
Print a brief help message and exits. When this options is repeated help text gets longer and longer. This options has a short form ``-h'' which accumulates. ``-hhh'' should give you the full documentation.

--verbose
Be verbose. This options has a short form ``-v'' which accumulates. ``-vv'' should give you highest level of verbosity.

--{no}radical
elimindate html parts in multipart/alternatives

--{no}recurse
recursively handle attached messages

--{no}flatten
merge headers of message/* only mails

--{no}augment
augment multipart/alternatives with a text/plain part

--{no}force
force a new text/plain part even if there is already one

--{no}dump
dump a possibliy modified mail to stdout

--{no}verify
verify parts that are cryptographically signed

--{no}from
prepend a \``From ...\'' line as a separator

--enc 'encoding-name'
use encoding-name for text/* part encoding

--qp
equivalent to --enc 'quoted-printable'

--8bit
equivalent to --enc '8bit'

--7bit
equivalent to --enc '7bit'

--multi
enforces multpart encoding

--keep
keep saved parts in temp directory for debugging

--install
install the script at some location, indicated by

--outdir=yourFilename
the name of the directory to install. `yourFilename' should be terminating with a slash or whatever is necessary on your system.


DESCRIPTION

normail will read the given input file and do someting useful with the contents thereof.

normail is a mail filter. Takes multipart or text/html from STDIN, normalizes some MIME-parts and reduces multipart/alternative to singlepart if possible.

Normalization

If a multipart/alternative would have several text/plain parts, all but one of them will be typed text/x-plain. The text/x-plain could be e.g the old bogus text/plain part as it was present in the input or the new part that we produced from text/html. The second version can be important if you want to make a bare text version of the mail visible for a spam catcher.

Finally (with option dump, default) writes cleaned MIME mail to STDOUT.

Verification


DOWNLOAD

You may find normail here: http://www.polarhome.com/~gustedt/normail.


INSTALLATION

Something like

yourFavoritePathToPerl yourTemporaryPath/normail --install --outdir=/usr/bin/

puts it in a place where your executables are found (here /usr/bin) and gives it executable rights. In addition it creates some symbolic links if possible.

See the description in source that is located near the head of the file if you encounter difficulties in making normail run properly.

System requirements

Try to have a recent version of perl installed. If your perl sits in an unconventional place try to run something like

      yourFavoritePathToPerl yourPathTo/normail

``Unconventional'' here means any other path than indicated in the first line of this script here. But if you followed the install instructions above, this should rarely be necessary. (Rarely here means systems that share a common file sytem, but not your path to perl.)

We need the following perl modules:

Getopt::Long
Pod::Usage
File::Temp
MIME::Parser

Html Mail

Furthermore we need an external program to convert html to plain text, like lynx, see http://lynx.browser.org/, or html2text, see http://userpage.fu-berlin.de/~mbayer/tools/html2text.html.

Therefore, we need at least one hint for successfully converting html to text. The variable $textifier serves for this purpose. It should contain a command line to be executed. You should put the strings #s for the source html file and #t for the target text file. Here come two examples.

If you have recent lynx. Beware that version 2.8.3 has a bug that breaks its use in a filter.

     my($textifier)="/usr/bin/lynx -dump -force_html file://localhost#s > #t";

I personally use this one, since the lynx on our system is outdated.

     my($textifier)="$ENV{HOME}/bin/html2text -nobs  -o #t #s";

Crytographic Signatures

Same idea holds for verifying multipart/signed mime mails or clearsigned text mails. Here #t stands for the text (message) file and #s for the file containing the signature. The program should send all interesting analysis to stdout.

      $verifier{"application/pgp-signed"}="gpg --verify #s #t 2>&1";
      $verifier{"text/pgp-signed"}="gpg --verify-files #t 2>&1";


EXAMPLES

Use it as filter on mail delivery, or interactively if some bogus mail is unreadable for your bare eyes.

FILTER

CAUTION: always test this script before you run it in production on real mail, otherwise you will loose.

With procmail, to normalize all multiparts:

    # Clean MIME mails
    :0
    * ^Content-Type:.*multipart/
    {
      :0c:
      tmp/normail
      :0fhbw
      | normail --from
    }

If your perl is at a different place than normal (what's that?) put something like

      | your-path-to-perl your-path-to-normail -from

INTERACTIVE

If run in a terminal, normail trys to use your favorite pager for output.

If you want to use it with VM in (X)Emacs when the sender supplied an unreadable textversion (or none at all) of his html-mail:

 (defalias 'normail
  (read-kbd-macro "e M-< C-SPC M-> C-u M-| norfilter RET C-c C-c"))
 (define-key vm-mode-map "+" 'normail)

When you want to verify structure and/or signature of mime mails:

 (defalias 'norver
  (read-kbd-macro "| C-SPC C-a C-w norver RET"))
 (define-key vm-mode-map "-" 'norver)


COPYRIGHT AND DISCLAIMER

Introduction

This code is public domain. It comes with absolutely no warranty. If it eats your mails for lunch, that's your problem. If you don't like this, don't use it.

Copyright

This program is Copyright 2003 by Jens Gustedt for all changes from the predecessors as cited in the ACKNOWLEDGEMENT.

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Disclaimer

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

More information

If you do not have a copy of the GNU General Public License write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


ACKNOWLEDGEMENT

 normail - normalizing mime encoded mail