I have a question. I'm generating a .pdf file from the mpdf library. After generating I saved on the server. Well, I'd like to generate the pdf file and not save on the server and yes, send them to the client's email. Even because the necessary data I save them in the database. I took an example on the web, however, it does not.
The shipping code.
<?php>
//recuperando os dados do cliente
$cliente = $_POST['cli_nome'];
$email_cli = $_POST['cli_email'];
$mpdf=new mPDF();
$mpdf->WriteHTML($pagina); <<<<
$content = $mpdf->Output('', 'S');
$content = chunck_split(base64_encode($content));
$mailto = $email_cli;
$from_name = 'Comercial SC';
$from_mail = '[email protected]';
//$replyto = '[email protected]';
$uid = md5(uniqid(time()));
$subject = 'Seu Boleto';
$message = 'Olá '. $cliente . '! Obrigado pela preferência.';
$filename = $arquivo;
$header = "From: ".$from_name." <" .$from_mail.">\r\n";
$header .= "Reply-To: ".$replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed: boundary=\"".$uid. "\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid. "\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--" .$uid. "\r\n";
$header .= "Content-Type: application/pdf; name=\"".$filename."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"" .$filename."\"\r\n\r\n";
$header .= $content. "\r\n\r\n";
$header .= "--".$uid."--";
$is_sent = @mail($mailto, $subject, "", $header);
$mpdf->Output();
exit;
?>
You're giving an error here in this line:
$content = chunck_split(base64_encode($content));
In fact, here I create the body of the file .pdf
:
//Criando arquivo pdf...
include('pdf/mpdf.php');
$pagina = ' <<<<<
<html>
(...)