Decoding a Base64 Email Attachment

This post was published 10 years, 10 months ago. Due to the rapidly evolving world of technology, some concepts may no longer be applicable.

I had a few files containing email attachments that needed to be converted into usable files. The following code (which has no checks in it), did the trick:

function decode_email_attachment(){
	$data= file_get_contents($inputfile);
	file_put_contents($outputfile, base64_decode(str_replace( "\r\n", "", $data )));

Leave a Reply

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