I've written a small recipe which will decode mail sent to me in NeXTMail
(basically just uudecoded and compressed text) format and turns it into
ASCII text instead.
What I would like to do, and have been unable to do, is this:
1) detect a NeXTMail message
2) perform the steps needed to convert the message to ASCII
(parts #1 and #2 I can do)
3) then pass the ASCII version of the message to the rest of the
procmailrc file for processing, or have it end up in $DEFAULT (with the
original header information still intact.
#3 is the tricky part, even after reading through the procmail* man pages.
I was trying to use the code from procmailex where it says:
The following example preconverts all plain-text mail arriv-
ing in certain encoded MIME formats into a more compact 8-
bit format which can be used and displayed more easily by
most programs. The mimencode(1) program is part of
Nathaniel Borenstein's metamail package.
but I'm not having too much luck, possibly because metamail is a single
command and I am issuing several commands.
This is what I have so far, if it helps:
SUBJECT=`formail -xSubject:`
FROM=`formail -xFROM:`
DATE=`formail -xDATE:`
:0
* ^Next-Attachment:*
{
:0 b
*.tar
| cat - > $HOME/nextmail.uue; \
uudecode $HOME/nextmail.uue; \
ATTACHMENT=`head -1 $HOME/nextmail.uue | awk '{print $3}'`;\
mv -f $ATTACHMENT $HOME/nextmail.tgz ; \
gzcat < $HOME/nextmail.tgz | gnutar xvf -;\
echo "From : $FROM" > "$HOME/nextmail.$DATE" ; \
echo "Subject: $SUBJECT" >> "$HOME/nextmail.$DATE" ; \
echo "Date : $DATE" >> "$HOME/nextmail.$DATE" ; \
rtf-ascii index.rtf >> "$HOME/nextmail.$DATE"
}
As you can see, it is rather ugly. The presence of a header line
"Next-Attachment" triggers the process which goes (as I understand it)
like this:
1) process the body
2) look for *.tar in the first line
3) cat the body to a file
4) uudecode that file
5) find the name of the uudecoded file
6) move that file to a more tolerable filename
7) use gzcat and gnutar to unarchive the message (which creates
a file called 'index.rtf')
8-10) put the FROM, SUBJECT, and DATE lines in a file
11) use 'rtf-ascii' to convert 'index.rtf' to ASCII and append that
to the file we created with steps 8-10
Not very eloquent, is it?
Basically what I'd really like to do is the same except that
instead of the output going to a file, I'd prefer that the original
headers be used with the ASCII version of the body (that is, the output
from 'rtf-ascii index.rtf') so that what ends up in m y mailbox is an
ASCII version of what once was an archived, uuencoded message, with the
original headers intact (so I can 'reply' and all that)
Any advice welcomed...
TjL
--
Timothy J. Luoma <luomat(_at_)capitalist(_dot_)princeton(_dot_)edu>
"Everything is easy when you know what you are doing"
Dr. Robert Cupper, Department of Computer Science,
Allegheny College, Meadville, PA