Hi:
I have writed a script that read a HTML file and convert this in a multipart mime but fail to send in a mail (is not interpreted).
But the result isn't interpreted lika a mime file!!
Somebody can see the error???
---------------------------
Code:
#! /bin/bash
SB=$1
IF=$2
OF=$3
rm -f $OF.b64
BND="------------$(date +%N)$(date +%N)"
# CUERPO DEL MENSAJE
echo -ne "Subject: $SB\n">$OF.tmp
# echo "Date: $(date)">>$OF.tmp
echo "MIME-Version: 1.0">>$OF.tmp
echo "Content-Type: multipart/related;">>$OF.tmp
echo -ne " boundary=\"$BND\"\n\n">>$OF.tmp
echo "This is a multi-part message in MIME format.">>$OF.tmp
echo "$BND">>$OF.tmp
echo "Content-Type: text/html; charset=ISO-8859-1">>$OF.tmp
echo -ne "Content-Transfer-Encoding: 7bit\n\n">>$OF.tmp
cat $IF>>$OF.tmp
echo -ne "\n\n$BND">>$OF.tmp
# MIME DE LOS ARCHIVOS
for n in $(cat $OF.tmp|tr -d '"'|awk '/<IMG SRC=/{A=substr($0,index($0,"SRC="));printf ("%s ",substr(substr(A,1,index(A," ")),5))}');do
ID="part1.$(date +%N).$(date +%N)@linux.org"
MITY=$(cat mime.types|awk -v MT="$(echo $n|awk '{for(i=length($0);i>=1;i--) if (substr($0,i,1)==".") {print substr ($0,i);break}}')" '{if (MT == $1) {printf("%s\n",$2);exit}}')
echo -ne "Convirtiendo: $n -> $ID\n"
echo -ne "\nContent-Type: $MITY;\n name=\"$n\"\nContent-Transfer-Encoding: base64\n">>$OF.b64
echo -ne "Content-ID: <$ID>\nContent-Disposition: inline;\n\n">>$OF.b64
# echo -ne filename=\"$n\"\n\n">>$OF.b64
base64 $n>>$OF.b64
echo -ne "$BND">>$OF.b64
cat $OF.tmp|sed "s/$n/cid:$ID/g">$OF.tmp
done
echo "--">>$OF.b64
cat $OF.tmp $OF.b64>$OF
This is an example of an output: