Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Decoding emails

0 views
Skip to first unread message

Iain Sharp

unread,
Oct 2, 2002, 6:35:55 AM10/2/02
to

We have a need for a script/program to parse an email file under SCO
and strip out and decode all the base64 encoded files contained in it.

Does anyone know of such a utility.

SCO 5.0.4 to 5.0.6, standard file format in /usr/spool/mail/xxxx
having been put in there by sendmail.

Better yet if the files can be decoded automatically as part of the
sendmail routing, but I've not had any success with the posted methods
of running sendmail to output via a script.

Iain Sharp
(Please e-mail as well, newsgroup access a tad spotty).

Stuart J. Browne

unread,
Oct 2, 2002, 6:58:32 PM10/2/02
to
"Iain Sharp" <ia...@pciltd.co.uk> wrote in message
news:vqilpuo435ht0n9g0...@4ax.com...

>
> We have a need for a script/program to parse an email file under SCO
> and strip out and decode all the base64 encoded files contained in it.
>
> Does anyone know of such a utility.
>
> SCO 5.0.4 to 5.0.6, standard file format in /usr/spool/mail/xxxx
> having been put in there by sendmail.
>
> Better yet if the files can be decoded automatically as part of the
> sendmail routing, but I've not had any success with the posted methods
> of running sendmail to output via a script.

You might want to look into thigns like 'mimedecode' (or 'mdecode'). I
don't they are distributed as part of the SCO OS' by default, but they
should be available as part of Skunkware.

Failing them, look at 'mutt'.

bkx


Greg M Lee

unread,
Oct 2, 2002, 9:29:54 PM10/2/02
to Iain Sharp
Iain Sharp wrote:
>
> We have a need for a script/program to parse an email file under SCO
> and strip out and decode all the base64 encoded files contained in it.
>
> Does anyone know of such a utility.
>
> SCO 5.0.4 to 5.0.6, standard file format in /usr/spool/mail/xxxx
> having been put in there by sendmail.
>
> Better yet if the files can be decoded automatically as part of the
> sendmail routing, but I've not had any success with the posted methods
> of running sendmail to output via a script.

Hi
I use this for all sorts of purposes.

1. Download the source of mpack/munpack and compile it

2. For each user xxxx either setup your script in their cron, or just
do it under root's cron. Something like the following:

User=xxxx
Work=/tmp/xxxx
[ -d $Work ] && mkdir $Work
cd $Work

while [ -s /usr/spool/mail/$User ]; do
# save message 1 and delete it
echo "save 1 .msg\nd1\nq" |
mail -u $User &&
munpack -q .msg
# do what you want with the message eg rm -f .msg
# do what you want with the extracted contents
done

Season the above to your taste ie permissions, timestamps, error
trapping, etc.

Enjoy
-Greg

Stuart J. Browne

unread,
Oct 3, 2002, 1:34:39 AM10/3/02
to
"Stuart J. Browne" <stu...@promed.com.au> wrote in message
news:anftml$1bs$1...@perki.connect.com.au...

... for the record, what we do is use uuencode, and a filter similar to:

---------------------------------------------------------------
#!/usr/bin/perl

$Export_Directory = "/usr/spool/uucppublic";

$File_Begin = 0;

while (<STDIN>) {
if (/^begin [0-7](?:[0-7]{2})? ([[:alnum:]\._-]+)/) {
$File_Begin = 1;
open( FILEHANDLE, "> $Export_Directory/$1");
}

if ($File_Begin) {
print FILEHANDLE unpack("u*", $_ );

if (/^end/) {
close( FILEHANDLE );
$File_Begin = 0;
}
}
}
---------------------------------------------------------------

set up as an alias (filedump: "| /usr/local/bin/filedump.filter") using
sendmail. Anything sent uuencoded to that address gets decoded automatically
and dumped.. But if you're receiving Mime messages, you'd have to make this
sort of routine more complex in order to grab out the file name from the
MIME header etc. etc.

bkx


0 new messages