Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to email a PDF as an attachment that was created using FPDF. but the attachment never comes through
    primarykey
    data
    text
    <p>I have written the following code to generate pdf and the pdf i generated fine and displayed,then in the second part i have written the code to generate mail automatically and send,but no response.. suggestions ? Thanks in advance :) </p> <pre><code> &lt;?php require('fpdf.php'); //Connect to your database $link = mysql_connect('xxxxx'); if (!$link) { die('Could not connect: ' . mysql_error()); } //Create new pdf file $pdf=new FPDF(); //Open file $pdf-&gt;Open(); //Disable automatic page break $pdf-&gt;SetAutoPageBreak(true); //Add first page $pdf-&gt;AddPage(); //set initial y axis position per page $y_axis_initial = 25; //print column titles for the actual page $pdf-&gt;SetFillColor(232, 232, 232); $pdf-&gt;SetFont('Arial', 'B', 12); $pdf-&gt;SetY($y_axis_initial); $pdf-&gt;SetX(5); /*$pdf-&gt;Cell(30, 6, 'CODE', 1, 0, 'L', 1); $pdf-&gt;Cell(30, 6, 'NAME', 1, 0, 'L', 1); $pdf-&gt;Cell(30, 6, 'PRICE', 1, 0, 'R', 1);*/ $y_axis = $y_axis + $row_height; //Select the Products you want to show in your PDF file /*$result=mysql_query('select Code,Name,Price from Products ORDER BY Code',$link);*/ mysql_select_db("brainoidultrafb", $link); $q = "SELECT qr_topics,start_of,differential_dia,things_not,investigations,risks FROM qr_table"; $result = mysql_query ($q, $link); //initialize counter $i = 0; //Set maximum rows per page $max = 25; //Set Row Height $row_height = 80; $pdf-&gt;Cell(33, 6, ' ', 1, 0, 'L', 1); $pdf-&gt;Cell(33, 6, 'Starting off', 1, 0, 'L', 1); $pdf-&gt;Cell(33, 6, 'Differential diagnosis', 1, 0, 'L', 1); $pdf-&gt;Cell(33, 6, 'Not to miss', 1, 0, 'L', 1); $pdf-&gt;Cell(33, 6, 'Investigations', 1, 0, 'L', 1); $pdf-&gt;Cell(33, 6, 'Risks', 1, 0, 'L', 1); $y_axis =(35); while($row = mysql_fetch_array($result)) { $cad = $row['qr_topics']; $pad = $row['start_of']; $nad = $row['differential_dia']; $vad = $row['things_not']; $sad = $row['investigations']; $tad = $row['risks']; $pdf-&gt;SetY($y_axis); $pdf-&gt;SetX(5); $pdf-&gt;Cell(33,80,$cad,1,0,'L',1); $pdf-&gt;Cell(33,80,$pad,1,0,'L',1); $pdf-&gt;Cell(33,80,$nad,1,0,'L',1); $pdf-&gt;Cell(33,80,$vad,1,0,'L',1); $pdf-&gt;Cell(33,80,$sad,1,0,'L',1); $pdf-&gt;Cell(33,80,$tad,1,0,'L',1); //Go to next row $y_axis = $y_axis + $row_height; $i = $i + 1; } mysql_close($link); //Send file //$pdf-&gt;Output(); //email test // email stuff (change data below) $to = "aneeshyyyy@gmail.com"; $from = "aneeshxxxx@gmail.com"; $subject = "Patient Report"; $message = "&lt;p&gt;Please see the attachment.&lt;/p&gt;"; // 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 = "test.pdf"; // encode data (puts attachment in proper format) $pdfdoc = $pdf-&gt;Output("", "S"); $attachment = chunk_split(base64_encode($pdfdoc)); // main header $headers = "From: ".$from.$eol; $headers .= "MIME-Version: 1.0".$eol; $headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\""; // no more headers after this, we start the body! // $body = "--".$separator.$eol; $body .= "Content-Transfer-Encoding: 7bit".$eol.$eol; $body .= "This is a MIME encoded message.".$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; // 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 mail($to, $subject, $body, $headers); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload