Decoding a Base64 Email Attachment

This post was published 2 years, 3 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 *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>