Bash email attachment
Hi all,
I recently wrote a small content filter script (in bash) to use on my
local Postfix installation. The script receives via "pipe:" the
recipient and the sender's addresses then responds by sending back a
message containing some body text and an image attachment.
It works as it is supposed to do, but with some email clients the image
is not displayed properly.
Gmail, Yahoo and MS Outlook detect the image as an attachment, but
Squirrelmail and my Blackberry only show garbled text.
Here's what a message looks like:
[headers]
[body]
begin 600 img.jpg
M_]C__@`.5$N5!Y(J````````__X`#DD!-@&D!P```&J2R__;`$,``P("`@("
M`P("`@,#`P,$!@0$!`0$"`8&!08)"`H*"0@)"0H,#PP*"PX+"0D-$0T.#Q`0
M$1`*#!(3$A`3#Q`0$/_;`$,!`P,#!`,$"`0$"!`+"0L0$!`0$!`0$!`0$!`0
M$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$!`0$/_``!$(`>`"
[...]
M"XD.U5'F(,9Y'%-RYG=F:5M!MX[%1!)'O#`D8Z[L]ZR5C7[3!;$%)IY-H4MP
MO.,FMU1-,T,@'F$-A\_>8_PBK&B^']9UGQ3I[6^FR`+,`TAZ#`S^/%:4X7=[
'"ERI6;/_V0``
`
end
To encode the image I use:
/usr/bin/uuencode img.jpg img.jpg > attachment.txt
cat hdr.txt body.txt attachment.txt > message.txt
$SENDMAIL "-f" $4 "--" $2 <message.txt
Anyone knows how to solve this?
Thanks
-RV
Reply to: