我正在使用DOMPDF发送pdf附件(我以前用TCPDF执行此操作,但TCPDF不支持CSS)
我收到了电子邮件,但电子邮件是1kb,无法打开。
我在TCPDF中找到了在DOMPDF中发送的电子邮件。我用谷歌搜索但找不到任何有用的东西。请帮助我
<?php
/* include autoloader */
require_once 'dompdf/autoload.inc.php';
/* reference the Dompdf namespace */
use Dompdf\Dompdf;
/* instantiate and use the dompdf class */
$dompdf = new Dompdf();
$html = ' HTML CONTENT';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
/* Render the HTML as PDF */
$dompdf->render();
//define the receiver of the email
$to = '[email protected]';
$subject = 'SUBJECT -';
$repEmail = '[email protected]';
$fileName = 'filename.pdf';
$fileatt = $dompdf->Output($fileName, 'E');
$attachment = chunk_split($fileatt);
$eol = PHP_EOL;
$separator = md5(time());
$headers = 'From: Identykidz <'.$repEmail.'>'.$eol;
$headers .= 'MIME-Version: 1.0' .$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
$message = "--".$separator.$eol;
$message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$message .= "Dear user. \r\n\r\nPlease find attached profile .\r\n".$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol;
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment".$eol.$eol;
$message .= $attachment.$eol;
$message .= "--".$separator."--";
// Send the email
if(mail($to, $subject, $message, $headers)) {
header("Location:successpage.php");
}
else {
echo "There was an error sending the mail.";
}
?>
<?php
/* include autoloader */
require_once 'dompdf/autoload.inc.php';
/* reference the Dompdf namespace */
use Dompdf\Dompdf;
/* instantiate and use the dompdf class */
$dompdf = new Dompdf();
$html = ' HTML CONTENT';
$dompdf = new DOMPDF();
$dompdf->load_html($html);
/* Render the HTML as PDF */
$dompdf->render();
**$pdf = $dompdf->output();**
//define the receiver of the email
$to = '[email protected]';
$subject = 'SUBJECT -';
$repEmail = '[email protected]';
$fileName = 'filename.pdf';
$fileatt = $dompdf->Output($fileName, 'E');
$attachment = chunk_split($fileatt);
$eol = PHP_EOL;
$separator = md5(time());
$headers = 'From: Identykidz <'.$repEmail.'>'.$eol;
$headers .= 'MIME-Version: 1.0' .$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"";
$message = "--".$separator.$eol;
$message .= "Content-Transfer-Encoding: 7bit".$eol.$eol;
$message .= "Dear user. \r\n\r\nPlease find attached profile .\r\n".$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$message .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$message .= "--".$separator.$eol;
$message .= "Content-Type: application/pdf; name=\"".$fileName."\"".$eol;
$message .= "Content-Transfer-Encoding: base64".$eol;
$message .= "Content-Disposition: attachment".$eol.$eol;
$message .= $attachment.$eol;
$message .= "--".$separator."--";
// Send the email
if(mail($to, $subject, $message, $headers)) {
header("Location:successpage.php");
}
else {
echo "There was an error sending the mail.";
}
?>