PHPMailer AddStringAttachment随附PDF
我是phpmailer的新手,我能够发送电子邮件、带有附件的电子邮件以及.txt文件的stringattachments,但是我不能发送带有PDF的stringattachments。已发送电子邮件,但PDF已损坏/无法打开。是否有人可以帮助发送AddStringAttachment,该附件是PDF格式而不是.txt格式?谢谢PHPMailer AddStringAttachment随附PDF,php,pdf,phpmailer,email-attachments,Php,Pdf,Phpmailer,Email Attachments,我是phpmailer的新手,我能够发送电子邮件、带有附件的电子邮件以及.txt文件的stringattachments,但是我不能发送带有PDF的stringattachments。已发送电子邮件,但PDF已损坏/无法打开。是否有人可以帮助发送AddStringAttachment,该附件是PDF格式而不是.txt格式?谢谢 <?php require_once('class.phpmailer.php'); $mail = new PHPMailer(); $body2 = "Yo
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$body2 = "You are receiving this email because the Transfer Application submitted for $Name transferring to $Receiving is missing required documentation.
Please see the note below for details. The transfer application will not be reviewed until all of the necessary materials are received by the UHSAA.
<p> Details:
$Notes ";
$mail->IsSMTP();
$mail->AddAddress($emailp);
$mail->AddCC('transfers@uhsaa.org');
$mail->AddStringAttachment($body2, 'Filename.pdf', 'base64', 'application/octet-stream');
$mail->Subject = "Test";
$body = ("See attachment");
$mail->MsgHTML($body);
$mail->AddAddress($address);
$mail->AddCC($address);
if(!$mail->Send())
;
?>
同样,如果我只是将Filename.pdf更改为Filename.txt,那么一切都正常,所以我假设问题在于编码,但我无法解决。请帮助我,以便我可以发送附件PDF。谢谢。试试看
$mail->AddStringAttachment($body2, 'Filename.pdf', 'base64', 'application/pdf');
它将工作无需区块分割base64编码pdf字符串
$mail->addStringAttachment($pdfString, 'vouchers.pdf');
这对我来说很好:
$mail->addStringAttachment(base64_decode($attachmentBase64),$filename)代码>“应用程序/八位字节流”*.pdf。不,它不是,它是一个文本字符串,称它为pdf并不能神奇地使它成为一个。我尝试了“application/pdf”,但在尝试打开电子邮件中的pdf作为“application/octet stream”时出现了相同的错误。它不是pdf,永远不会是pdf,它是一个文本字符串。你得到了什么?请解释解决方案无需指定编码和MIME类型-两者都将自动设置。这两种代码都不起作用:$mail->AddStringAttachment($body2,'Filename.pdf','base64','application/octet stream')$mail->addStringAttachment($body2,'decisions.pdf')$mail->AddStringAttachment($body2,'Filename.pdf','base64','application/pdf');即使这样也不行是的,那是我的问题。需要先解码字符串。