我有这段代码,它将 PDF 编码的文件作为从另一个窗口生成的 Base64 URI 字符串,并声明为 php 会话变量,最后这是我正在编码的函数,它发送电子邮件,但使用 Base64 解码作为大量字符,而不是正确完成的附件。
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; }
}
Run Code Online (Sandbox Code Playgroud)