Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试使用Phpmailer添加多个附件文件_Php_Email_Attachment_Phpmailer - Fatal编程技术网

尝试使用Phpmailer添加多个附件文件

尝试使用Phpmailer添加多个附件文件,php,email,attachment,phpmailer,Php,Email,Attachment,Phpmailer,我有两个文件在我的服务器上,我想加入我的邮件(由tcpdf生成,然后由phpmailer生成),但它不工作,pdf发送时没有附加文件。这是我的密码: function SENDmail($pdf) { // $pdf is generated by tcpdf $mails = explode (";", $_REQUEST['YOU']); $files = explode ('</br>', $_REQUEST['FILES']); //all my files are li

我有两个文件在我的服务器上,我想加入我的邮件(由tcpdf生成,然后由phpmailer生成),但它不工作,pdf发送时没有附加文件。这是我的密码:

 function SENDmail($pdf) { // $pdf is generated by tcpdf
$mails = explode (";", $_REQUEST['YOU']);

$files = explode ('</br>', $_REQUEST['FILES']); //all my files are like 'blabla.png' or 'blabla.pdf' and are separated by </br>

require_once('phpmailer/class.phpmailer.php');
$mailer = new PHPMailer();
$mailer->IsHTML(true); 
$mailer->CharSet = 'UTF-8';
$mailer->AddReplyTo($_REQUEST['MAIL'], 'Reply To');
$mailer->SetFrom($_REQUEST['MAIL'], $_REQUEST['MAIL']);

foreach ($mails as $mail)
{
    $mailer->AddAddress($mail, 'Send To');
}

foreach ($files as $file)
{
    $mailer-> AddAttachment('../extension/server/php/files/'.$file); /*Can I put the path like that?*/

}
$mailer->Subject = 'blabla';
$mailer->AltBody = "To view the message, please use an HTML compatible email viewer";


$newline = nl2br($_REQUEST['CONT']);
$mailer->Body = $newline;

if ($pdf) {$mailer->AddStringAttachment($pdf, 'blabla on '.date('l jS \of F Y').'.pdf');}

$mailer->Send();
}



$attachment = $pdf->Output('blabla on '.date('l jS \of F Y').'.pdf', 'S');
SENDmail($attachment);
函数SENDmail($pdf){/$pdf由tcpdf生成
$mails=explode(“;”,$_请求['YOU']);
$files=explode(“
”,$\u REQUEST['files']);//我的所有文件都类似于“blabla.png”或“blabla.pdf”,并用
一次需要_('phpmailer/class.phpmailer.php'); $mailer=新的PHPMailer(); $mailer->IsHTML(true); $mailer->CharSet='UTF-8'; $mailer->AddReplyTo($_请求['MAIL'],'Reply To'); $mailer->SetFrom($_请求['MAIL'],$_请求['MAIL']); foreach($mails作为$mail) { $mailer->AddAddress($mail,'Send To'); } foreach($files作为$file) { $mailer->AddAttachment('../extension/server/php/files/'.$file);/*我可以这样放置路径吗*/ } $mailer->Subject='blabla'; $mailer->AltBody=“要查看邮件,请使用与HTML兼容的电子邮件查看器”; $newline=nl2br($_请求['CONT']); $mailer->Body=$newline; if($pdf){$mailer->AddStringAttachment($pdf,'blabla on'.date('l jS\of F Y')。.pdf');} $mailer->Send(); } $attachment=$pdf->Output('blabla on'.date('l jS\of F Y')。.pdf',S'); SENDmail(附件);

感谢

可能重复@Nomi我没有显示任何错误,我认为这更像是tcpdf和phpMail之间的冲突问题,因为我已经在邮件中使用了附件以加入pdfcan您可以附加单个文件吗$file的输出是什么,绝对路径是否正确