Ubuntu Linux unpack mime encoded mail files

Sometimes when clients forward emails through the encoding gets stuffed up and you end up with an attachment that contains the clients message along with any files.

If you open this attachment in notepad or whatever you will see all the email headers and stuff like this:

Received: from blah.example.com
Return-Path: blah@example.com
Date: Mon, 23 Nov 2009 13:17:59 +1100
Message-ID: <C7303C12.5ED2%eexample@example.com>
MIME-Version: 1.0
Content-Type: multipart/mixed;
        boundary="----=_NextPart_000_02BF_01CA6C52.F949EC90"
X-Mailer: Microsoft Office Outlook 12.0

This is a multi-part message in MIME format.
etc....

When you run `file` on this you will get something like this:

$ file the_downloaded_attachment
the_downloaded_attachment: RFC 822 mail text

To unpack the contents of this file, install the munpack package and simply do this:

munpack the_downloaded_attachment

and it will spit out all the encoded files.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *