简体   繁体   中英

Send generated PDF with DomPdf as attachment with PHPMailer

I have been able to use dompdf to stream output but how can I make it send via email

use Dompdf\Dompdf;
$dompdf = new Dompdf();
$image = "../img/logo2.png";
$html = '<h1>Hello World</h1>' ;

$dompdf->load_html($html);

// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');

// Render the HTML as PDF
$dompdf->render();
$domdpf->stream();

how can I make it send via PHPMailer Thanks

Change your last line to $pdf = $dompdf->output();

Then you can use the addStringAttachment function in PHPMailer ( https://phpmailer.github.io/PHPMailer/classes/PHPMailer.PHPMailer.PHPMailer.html#method_addStringAttachment )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM