normail - normalizing mime encoded mail |
normail - normalizing mime encoded mail
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 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.
--enc 'quoted-printable'
--enc '8bit'
--enc '7bit'
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.
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.
You may find normail
here: http://www.polarhome.com/~gustedt/normail.
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.
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:
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";
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";
Use it as filter on mail delivery, or interactively if some bogus mail is unreadable for your bare eyes.
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
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)
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.
This program is Copyright 2003 by Jens Gustedt for all changes from the predecessors as cited in the ACKNOWLEDGEMENT.
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.
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.
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.
normail - normalizing mime encoded mail |