php - getting blank pdf file attachment using phpmailer and mpdf -
php - getting blank pdf file attachment using phpmailer and mpdf -
i'm using mpdf generate pdf's when button clicked , save them within folder. looking way add together pdf attachment using phpmailer. here i've tried:
$dir = $_server['document_root'].dirname($_server['php_self']); $pdfexist = $dir."/classes/pdf/feestructure_".$student['rollno'].".pdf"; $mail = new phpmailer; $mail->issmtp(); $mail->from="xyz@abc.com"; $mail->fromname="xyz"; $mail->addaddress("xyz@abc.com"); //echo $email."<br/>"; $mail->addaddress("xyz@abc.com"); $mail->addaddress("xyz@abc.com"); $mail->subject = 'xyz'; $pdfstring = $pdfexist; $mail->addstringattachment($pdfstring, "feestructure_".$roll.".pdf", $encoding = 'base64', $type = 'application/pdf');
the size of generated pdf 13k showing 1 k in mail service attachment.help me guys.
here output mpdf:
$mpdf->writehtml(file_get_contents("$dir/feestructure_pdf.php?rollno=$rollno")); $pdfname="feestructure_".$rollno.".pdf"; $mpdf->output("classes/pdf/".$pdfname,"f");
your $pdfexists
/ $pdfstring
variable contains file path, not binary pdf data, should using addattachment()
, not addstringattachment()
. addattachment attaches files (like pdf), addstringattachment attaches strings, might web phone call or database.
$mail->addattachment($pdfstring, "feestructure_".$roll.".pdf", $encoding = 'base64', $type = 'application/pdf');
php phpmailer mpdf
Comments
Post a Comment