How to use TCPDF with PHP mail function

后端 未结 2 530
一个人的身影
一个人的身影 2021-02-10 18:00
$to = \'my@email.ca\';
$subject = \'Receipt\';
$repEmail = \'rep@sales.ca\';

$fileName = \'receipt.pdf\';
$fileatt = $pdf->Output($fileName, \'E\');
$attachment = ch         


        
2条回答
  •  滥情空心
    2021-02-10 18:26

    You have two choices. You can save the PDF to a file and attach the file or else output it as a string. I find the string output is preferable:

    $pdfString = $pdf->Output('dummy.pdf', 'S');
    

    The file name is ignored since it just returns the encoded string. Now you can include the string in your email. I prefer to use PHPMailer when working with attachments like this. Use the AddStringAttachment method of PHPMailer to accomplish this:

    $mailer->AddStringAttachment($pdfString, 'some_filename.pdf');
    

提交回复
热议问题