我成功生成了发票pdf,并且能够使用PHP邮件一起发送电子邮件和附件。但是问题是-当我在浏览器中呈现pdf时,它会显示所有内容,但是当我使用附件将其发送到电子邮件时,它不会显示某些内容。并且还向我建议了一些有关如何使用SMTP发送附件的提示,我进行了一些研究,但未成功。但首先,我需要解决这个问题,即在使用附件时不会生成pdf中的所有内容。
代码在这里
include('../phpinvoice.php');
$invoice = new phpinvoice();
/* Header Settings */
$invoice->setLogo("images/logo.png");
$invoice->setColor("#007fff");
$invoice->setType("Sale Invoice");
$invoice->setReference($appid);
$invoice->setDate(date('M dS ,Y',time()));
$invoice->setTime(date('h:i:s A',time()));
//$invoice->setDue(date('M dS ,Y',strtotime('+3 months')));
$invoice->setDue($timestamp);
$invoice->setFrom(array("Indian e-VISA Service","JSD Innovations Private Limited","128 AA Juanita Ave","Delhi , New Delhi 110072","India"));
$invoice->setTo(array($fullname,$preadd1 .' ' .$preadd2,$preadd3.' '.$pincode,$precountry,$clcode.' '.$phone));
/* Adding Items in table */
$invoice->addItem("Indian e-VISA Application",$appltype,1,0,$fee,0,$fee);
//$invoice->addItem("PDC-E5300","2.6GHz/1GB/320GB/SMP-DVD/FDD/VB",4,0,645,0,2580);
//$invoice->addItem('LG 18.5" WLCD',"",10,0,230,0,2300);
//$invoice->addItem("HP LaserJet 5200","",1,0,1100,0,1100);
/* Add totals */
$invoice->addTotal("Total",$fee);
//$invoice->addTotal("VAT 21%",1986.6);
$invoice->addTotal("Total due",$fee,true);
/* Set badge */
$invoice->addBadge("Payment Paid");
/* Add title */
$invoice->addTitle("Important Notice");
/* Add Paragraph */
$invoice->addParagraph("No item will be replaced or refunded if you don't have the invoice with you. You can refund within 2 days of purchase.");
/* Set footer note */
$invoice->setFooternote("Disclaimer : www.indian-evisas.org.in is responsible for full visa services to India. This is a commercial website to apply eVisa to India through Indian Government Website, you will be charged a fee for using our services. Our fee will be higher than Indian Government if you apply through the Indian Embassy or website. Read all our Terms and Conditions carefully before using our services.");
/* Render */
//$invoice->render(''.$appid.'.pdf','I'); /* I => Display on browser, D => Force Download, F => local path save, S => return document path */
//$attachment= $invoice->Output('attachment.pdf', 'S');
$pdfdoc = $invoice->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
// email stuff (change data below)
$to = "gaurav@ojibix.com";
$from = "gaurav@ojibix.com";
$subject = "E-Visa Application Invoice Details";
$message = "<p>Please see the attachment.</p>";
// a random hash will be necessary to send mixed content
$separator = md5(time());
// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;
// attachment name
$filename = ''.$appid.'.pdf';
$headers = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$body .= "Content-Transfer-Encoding: 7bit".$eol;
$body .= "This is a MIME encoded message.".$eol; //had one more .$eol
// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol; //had one more .$eol
// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";
// send message NOTICE I replaced "" with $body
mail($to, $subject, $body, $headers);