Recover attachments from email text file

Sometimes it’s useful to be able to extract the attachment from an email when you’ve just got the plain text (well the encoded attachment) file to hand. You can make use of OpenSSL to decode the attachment data. Copy the encoded attachment bit of the email into a new file and use openssl thus:

openssl base64 -d -in infile -out outfile

Conversely, if you wanted to encode to Base64:

base64 -in infile -out outfile

Where infile and outfile are your email attachment saved to a file and the file to save the decoded attachment in respectively.

Written on 28 Dec 2008 and categorised in CommandLine and NIX, tagged as email, ssl, base64, and attachement

Home, Post archive

site copyright Eric Freeman

Valid XHTML 1.0 Strict