Decoding a Base64 Email Attachment

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 )));
}
?>

By cyberx86

Just a random guy who dabbles with assorted technologies yet works in a completely unrelated field.

Leave a comment

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