How to use TCPDF with PHP mail function

后端 未结 2 525
一个人的身影
一个人的身影 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:17

    I tried several alternatives. Only way that worked was when I saved the PDF to a folder and then email it.

    $pdf->Output("folder/filename.pdf", "F"); //save the pdf to a folder
      require_once('phpmailer/class.phpmailer.php'); //where your phpmailer folder is
    $mail = new PHPMailer();                    
    $mail->From = "email.com";
    $mail->FromName = "Your name";
    $mail->AddAddress("email@yahoo.com");
    $mail->AddReplyTo("email@gmail.com", "Your name");               
    $mail->AddAttachment("folder/filename.pdf");      // attach pdf that was saved in a folder
    $mail->Subject = "Email Subject";                  
    $mail->Body = "Email Body";
    if(!$mail->Send())
    {
           echo "Message could not be sent. 

    "; echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent"; } echo 'sent email and attachment';

提交回复
热议问题