我有这段代码,它将以Base64 URI字符串编码的PDF文件作为PHP会话变量从另一个窗口生成,最终这是我正在编写的函数,它发送电子邮件,但是附件被解码为大量字符,而不是正确完成的附件。
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; }
}