小编San*_*Pol的帖子

base64 字符串转换成邮件附件 pdf

我有这段代码,它将 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)

php pdf email base64 attachment

3
推荐指数
1
解决办法
3941
查看次数

标签 统计

attachment ×1

base64 ×1

email ×1

pdf ×1

php ×1