As a \"look under the covers\" tutorial for myself I am building a PHP script to gather emails from a POP3 mailbox. While attempting to make use of binary attachments I am
function base64_decode_file($data) { if(preg_match('/^data\:([a-zA-Z]+\/[a-zA-Z]+);base64\,([a-zA-Z0-9\+\/]+\=*)$/', $data, $matches)) { return [ 'mime' => $matches[1], 'data' => base64_decode($matches[2]), ]; } return false; }