小编use*_*333的帖子

带有PDF的PHPMailer AddStringAttachment

我是phpmailer的新手,我能够发送电子邮件,带附件的电子邮件,以及.txt文件的字符串附件但是我无法发送带PDF的字符串附件.电子邮件已发送,但PDF已损坏/无法打开.任何人都可以帮助发送AddStringAttachment,附件是PDF而不是.txt吗?谢谢

<?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())

;
?>
Run Code Online (Sandbox Code Playgroud)

同样,如果我只是将Filename.pdf更改为Filename.txt一切正常,所以我假设问题是编码,但我无法弄明白.请帮忙,这样我就可以发送stringattachment PDF了.谢谢.

php pdf phpmailer email-attachments

8
推荐指数
3
解决办法
2万
查看次数

标签 统计

email-attachments ×1

pdf ×1

php ×1

phpmailer ×1