Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This ended up working for me:</p> <pre><code>&lt;?php require('lib/fpdf/fpdf.php'); $pdf = new FPDF('P', 'pt', array(500,233)); $pdf-&gt;AddFont('Georgiai','','georgiai.php'); $pdf-&gt;AddPage(); $pdf-&gt;Image('lib/fpdf/image.jpg',0,0,500); $pdf-&gt;SetFont('georgiai','',16); $pdf-&gt;Cell(40,10,'Hello World!'); // email stuff (change data below) $to = "myemail@example.com"; $from = "me@example.com"; $subject = "send email with pdf attachment"; $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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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