RE: [exim] Adding those Legal disclaimers to e-mails

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Kjetil Torgrim Homme
Dátum:  
Címzett: David Brodbeck
CC: exim
Tárgy: RE: [exim] Adding those Legal disclaimers to e-mails
On Thu, 2005-04-28 at 05:00 +0200, Kjetil Torgrim Homme wrote:
> to do it properly, you encapsulate the message in a multipart/mixed with
> two parts: one the original MIME entity, the other your disclaimer text.
> MIME is after all a recursive structure, so you can do manipulations
> like these at will. I don't know what the big deal about this is, it's
> less than a dozen lines of Bourne shell script. if you want to make it
> hard, you could code it up in Befunge, I guess.


this may have come across as pretty cocky, so here's the script. it got
a bit longer than a dozen lines -- I wanted it to be readable, after
all :-) note that there should be a literal TAB in the second case
statement.

this should be RFC compliant, except for one thing: it does not verify
that the boundary actually is unique. to do that you need to use
temporary files, and I couldn't be bothered.

#! /bin/sh

msg="You shouldn't be reading my message."
IFS= read h
while IFS= read l; do
   case $h in "") break ;; esac
   case $l in "[     ]"*) h="$h
$l"; continue ;; esac
   case $h in [Cc][Oo][Nn][Tt][Ee][Nn][Tt]-*) mime="$mime$h"; h="$l";
continue ;;
              [Mm][Ii][Mm][Ee]-[Vv][Ee][Rr][Ss][Ii][Oo][Nn]:*) h="$l";
continue ;;
   esac
   echo "$h"
   h="$l"
done
bound="-=-$$-`uname -n`-"
printf "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=
$bound\n\n"
printf "%s\n%s\n\n" "$bound" "$mime"
cat
printf "%s\nContent-Type: text/plain\n\n%s\n\n--%s\n" "$bound" "$msg"
"$bound"


--