title: How do I send a FPDF doc using PHPMailer
body: <p>I would like to merge or link the FPDF and PHPMailer code so that a document is generated and sent by email.  I do not want to save the file.  I am unable to find a solution.  Below is the working code for FPDF and also for PHPMailer.  Unable to merge the two together.</p>
  
  <p>FPDF website says to do this</p>
  
  <pre><code>$mail = new PHPMailer();
  ...
  $doc = $pdf-&gt;Output('', 'S');
  $mail-&gt;AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf');
  $mail-&gt;Send();
  </code></pre>
  
  <p>FPDF code:</p>
  
  <pre><code>require_once('fpdf/fpdf.php');
  $fpdf = new FPDF();
  $text="test";
  
  $fpdf-&gt;SetMargins(0, 0, 0);
  $fpdf-&gt;SetAutoPageBreak(true, 0);
  
  define('FPDF_FONTPATH', 'font/');
  
  $fpdf-&gt;AddFont('Verdana', '','verdana.php'); // Standard Arial
  
  $fpdf-&gt;addPage('L');
  
  $fpdf-&gt;Image('images/certificate.jpg', 0, 0, 297, 210);
  
  $fpdf-&gt;SetFont('Verdana', '');
  $fpdf-&gt;SetFontSize(28);
  $fpdf-&gt;SetTextColor(32, 56, 100); 
  $fpdf-&gt;SetXY(108, 52); //
  $fpdf-&gt;Cell(80, 6, $text, 0,0, 'C'); 
  
  $fpdf-&gt;Output('Filename.pdf', 'i');
  </code></pre>
  
  <p>PHPMailer code:</p>
  
  <pre><code>require 'phpmailer/PHPMailerAutoload.php';
  $mail = new PHPMailer;
  $mail-&gt;IsSMTP();                                // Set mailer to use SMTP
  $mail-&gt;Host = 'gator3095';                      // Specify main and backup server
  $mail-&gt;Port = 587;                              // Set the SMTP port
  $mail-&gt;SMTPAuth = true;                         // Enable SMTP authentication
  $mail-&gt;Username = 'username';                   // SMTP username
  $mail-&gt;Password = 'password';                   // SMTP password
  $mail-&gt;SMTPSecure = 'tls';                      // Enable encryption, 'ssl' also accepted
  $mail-&gt;From = 'test@hotmail.com.com';
  $mail-&gt;FromName = 'John Doe';
  $mail-&gt;AddAddress('recipient@hotmail.com', '');  // Add a recipient
  $mail-&gt;IsHTML(true);                             // Set email format to HTML
  
  $mail-&gt;Subject = 'subject';
  $mail-&gt;Body    = 'message body';
  $mail-&gt;AltBody = 'messge body';
  $mail-&gt;AddAttachment("c:/temp/test.php", "test.php");  
  
  if(!$mail-&gt;Send()) {
     echo 'Message could not be sent.';
     echo 'Mailer Error: ' . $mail-&gt;ErrorInfo;
     exit;
  }
  echo 'Message has been sent';
  </code></pre>