我需要将客户填写的表格细节以pdf格式作为附件发送给店主,它不会用php mail()方法发送pdf,它可以用phpmailer()正常工作
require_once("dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($message1);
$dompdf->render();
//$dompdf->stream("sample.pdf");exit;
$pdf = $dompdf->output();
$attachment = chunk_split(base64_encode($pdf));
$filename = "vendor.pdf";
$mail = new Mail($config->get('config_mail'));
//$mail = new Mail();
$mail->addStringAttachment($pdf, $filename, $encoding = 'base64', $type = 'application/pdf', $disposition = 'attachment');
$mail->setTo('owneremail@yahoo.com');
$mail->setFrom($config->get('config_email'));
//$mail->setFrom('info@mdpocket.com');
$mail->setSender($config->get('config_name'));
$mail->setSubject('Vendor Form');
$mail->setText("Find Attached Files");
$mail->addAttachment($path_of_uploaded_file);
$mail->send();
addStringAttachment()函数在mail()方法中不起作用。我如何发送PDF文件?
1条答案
按热度按时间cs7cruho1#
嗨这个示例代码你可以用这个来发送pdf或word文件使用PHP邮件功能
$到=”developer@gamil.com“;
$subject =“您好,此PDF文件“;
//这里我们粘贴我们的谷歌驱动器链接到消息$message ='https://docs.google.com/document/d/1GZGVSLmXTfnBQX_dNh4esroJIJXsUPvR/edit?usp=共享&ouid= 111383270774979041580 & rtpof =true&sd= true';$header =“用daya编程”;
邮件($收件人,$主题,$邮件,$标题);
//在本教程中我们使用邮件功能发送pdf或word文件