Sometimes e-mails are stored as a plain text file. This might be due to backup solutions or as in my case, sometimes I have to save e-mails in text format because the client has issues with more complicated S/MIME mails with attachments.
In such cases the text file itself contains the multipart message body of the e-mail, so the attachments are provided as base64 streams:
--------------060903090608060502040600 Content-Type: application/x-gzip; name="liquidat.tar.gz" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="liquidat.tar.gz" qrsIAstukk4AA+17Wa+jSpZuPfMrrK6Hvi1qJ4OxsfuodQU2YLDBUJDGrvqBeR7MaPj1N7D3 OEmSxO8Wq7+3Y48dTWvXi8XvvKj8od6vPf9vKjWIv1v7nt3G/d8rEX5D/FdrDIxj2IrUPeE/ j5Dv4g9+fPnTRcX006T++LdYYw7w+i...
These data can be extracted manually, but that’s a wearisome task. It’s easier to use munpack, which can easily extract attachment(s) out of such text files and write them into a proper named files.
$ munpack -f mail.txt liquidat.tar.gz (application/x-gzip)