Decoding a Base64 Email Attachment

This post was published 8 years, 9 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:

<?php
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 *