i have this code that takes a PDF encoded file as a Base64 URI string that is generated from another window and is declared as a php session variable, finally this is the function that i'm coding and it sends the email but with the Base64 decoded as tons of characters, not as a attachment properly done.
function MailWithAttachment($to, $subject, $message, $senderMail, $senderName, $files){
$from = $senderName." <".$senderMail.">";
$headers = "From: $from";$headers = "MIME-Version: 1.0$newline".
"Content-Type: application/pdf;".
"boundary = \"$boundary\"$newline$newline".
"--$boundary$newline".
"Content-Type: application/pdf; charset=ISO-8859-1$newline; Content-Disposition: attachment;".
"Content-Transfer-Encoding: base64$newline$newline";
echo "<script>alert('$files')</script>";
$headers .= rtrim(chunk_split($files));
$returnpath = "-f" . $senderMail;
//send email
$mail = @mail($to, $subject, $message, $headers, $returnpath);
if($mail){ return TRUE; } else { return FALSE; }
}