Jump to content

This CODE!!


RON_ron

Recommended Posts

<?php
require("/fpd/fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont("Arial","B",14);
$pdf->Cell(40,10, "this is a <strong class="highlight">pdf</strong> example");
$to = "[email protected]"; 
$from = "BBQ"; 
$subject = "<strong class="highlight">send</strong> <strong class="highlight">email</strong> with <strong class="highlight">pdf</strong> attachment"; 
$message = "<p>Please see the attachment.</p>";
$separator = md5(time());
$eol = PHP_EOL;
$filename = "example.pdf";
$pdfdoc = $pdf->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; 
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
$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."--";
mail($to, $subject, "", $headers);
mail($to, $subject, "", $headers);
?>

Link to comment
https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939523
Share on other sites

As per fpdf.org

 

Output

string Output([string name, string dest])

 

Description

 

Send the document to a given destination: browser, file or string. In the case of browser, the plug-in may be used (if present) or a download ("Save as" dialog box) may be forced.

The method first calls Close() if necessary to terminate the document.

Parameters

 

name

The name of the file. If not specified, the document will be sent to the browser (destination I) with the name doc.pdf.

dest

Destination where to send the document. It can take one of the following values:

I: send the file inline to the browser. The plug-in is used if available. The name given by name is used when one selects the "Save as" option on the link generating the PDF.

D: send to the browser and force a file download with the name given by name.

F: save to a local file with the name given by name (may include a path).

S: return the document as a string. name is ignored.

Link to comment
https://forums.phpfreaks.com/topic/178190-this-code/#findComment-939557
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.