Pdf library download and link
Github link:: https://github.com/iafan/html2pdf
****************************
/* invoice send to user through email*/
/**/
$mailto = 'iww.xxxx@gmail.com';
$mailfrom = 'info@xxxxx.net';
$mailsubject = 'Recharge Invoice';
$firstname = 'testt';
$lastname = 'testk kl';
$description = 'svjisvs geg g e ';
$description = wordwrap($description, 100, "<br />");
/* break description content every after 100 character. */
$content = '';
$content .= '
<style>
table {
border-collapse: collapse;
}
table{
width:800px;
margin:0 auto;
}
td{
border: 1px solid #e2e2e2;
padding: 10px;
max-width:520px;
word-wrap: break-word;
}
</style>
';
/* you css */
$content .= '<table>';
$content .= '<tr><td>Mail To</td> <td>' . $mailto . '</td> </tr>';
$content .= '<tr><td>Mail From</td> <td>' . $mailfrom . '</td> </tr>';
$content .= '<tr><td>Mail Subject</td> <td>' . $mailsubject . '</td> </tr>';
$content .= '<tr><td>Firstname</td> <td>' . $firstname . '</td> </tr>';
$content .= '<tr><td>Lastname</td> <td>' . $lastname . '</td> </tr>';
$content .= '<tr><td>Description</td> <td>' . $description . '</td> </tr>';
$content .= '</table>';
require_once('html2pdf/html2pdf.class.php');
$to = $mailto;
$from = $mailfrom;
$subject = $mailsubject;
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->WriteHTML($content);
$message = "<p>Please see the attachment.</p>";
$separator = md5(time());
$eol = PHP_EOL;
$filename = "pdf-document.pdf";
$pdfdoc = $html2pdf->Output('', 'S');
$attachment = chunk_split(base64_encode($pdfdoc));
$headers = "From: " . $from . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
$body = '';
$body .= "Content-Transfer-Encoding: 7bit" . $eol;
$body .= "This is a MIME encoded message." . $eol; //had one more .$eol
$body .= "--" . $separator . $eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $eol;
$body .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
$body .= $message . $eol;
$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 . "--";
if (mail($to, $subject, $body, $headers)) {
$msgsuccess = 'Mail Send Successfully';
} else {
$msgerror = 'Main not send';
}
/* invoice send to user through email*/
No comments:
Post a Comment