I am creating a simple database where I can run a 1 click email with a PDF attached. Currently I'm running that with the TCPDF function but I want to be able to send data to the PDF script using AJAX.
If someone can reference to what I need to read up on I would be grateful as most examples I can find only include pulling data from text files
For example:
<a href="tcpdf/PDF/testPDF.php?firstname=Ralph&datetime=2014-07-10 09:15:00&[email protected]" target="_blank">Send Invitation</a>
If it helps here is my mail code:
// random hash necessary to send mixed content
$separator = md5(time());
$eol = PHP_EOL;
// attachment name
$filename = "Invitation.pdf";
// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));
///////////HEADERS INFORMATION////////////
// main header (multipart mandatory) message
$headers = "From: test<[email protected]>".$eol;
$headers .= "Bcc: [email protected]".$eol;
$headers .= "MIME-Version: 1.0".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
// message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
// attachment
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
//Email message
mail($emailto, $emailsubject, $emailbody, $headers);