PHP使用PHP Mail()函数发送带有PDF附件的电子邮件



我需要以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文件?

嗨,您可以使用此示例代码使用PHP邮件函数发送PDF或Word文件:

$to ="developer@gamil.com";
$subject ="Hi this pdf file ";
//here we paste our google drive link to in message 
$message ='https://docs.google.com/document/d/1GZGVSLmXTfnBQX_dNh4esroJIJXsUPvR/edit?usp=sharing&ouid=111383270774979041580&rtpof=true&sd=true';
$header ="programmingwithdaya";
mail($to,$subject,$message,$header);

在本教程中,我们使用邮件功能发送PDF或Word文件

$ to = =;$ objection =&quort hi this pdf文件"

//在这里我们将Google驱动器链接粘贴到消息中$ message ='https://docs.google.com/document/d/1gzgvslmxtfnbqx_dnh4esrojijxsupvr/edit?usp = usp =共享$ header ="文件标题";邮件($ to,$ object,$消息,$ header);

最新更新