I'm in the cur folder of a maildir store.
I want to cat a message .. pipe it to a command .. and have the body of the message spit out. Simple.
Example:
If its a mime message .. and there is a plaintext version .. show me the plaintext ..
If its an HTML message with no plaintext .. then render the HTML and give me some semblence of the message text …
If its just an image … display nothing .. or maybe an [image] placeholder ..
Why do I want this?
I'm trying to train spamassassin .. and I want to spit out key headers and an excerpt from the email body so I can quickly skim through all the messages and decide which ones are legit, which are ham, and which are spam …
I am already extracting a list of messages from the maildir that match a given X-Spam score .. and am displaying the headers I want .. I just need to append the body of the message .. but hit a roadblock
Some other questions here suggested using mutt. I installed that and looked at it – but from what I could see – I'd have to point it to the specific maildir .. which is going to complicate the process .. ideally I'd like something that just "interprets" an email message from a file and displays it
Your help is appreciated.
Thank You
Best Answer
I've managed to come up with the following script .. but its still a bit lacking. Was still refining it when I noticed Andrew suggested
munpack
from thempack
packageI found the tool
reformime
to extract the plain/text portion of the mime message. I was using GNUrecode
too but found that it was stripping stuff that wasn't quoted printable (QP) .. so I elected to usesed
, probably quite inefficiently, to remove the QP code .. and substitute common characters that were QP escaped.Here's the script I came up with .. I can go into a maildir folder now - run the script .. and get a summary of messages. Supplying an argument will match specific scores using regexp.
As an example:
OUTPUT: (finds one message)