title: Simple PDF file attachment in PHP Mailer
body: <p>I'm trying the simplest way to send an -email- with -an attached file- using PHP mailer. </p>
  
  <p>I tried using this </p>
  
  <pre><code>   $mail -&gt;addAttachment("path_to_pdf", "pdf_name);
  </code></pre>
  
  <p>but it does't work, since the "Mail is sent" but the "PDF file attachment" is not sent.</p>
  
  <p>Please help me solve my problem, I want to attach a pdf file in the email I want to send to the receiver. Thanks!</p>
  
  <p>Here are the files I used to send email w/file attachment.</p>
  
  <p>the index.html</p>
  
  <pre><code>        &lt;html&gt;
          &lt;head&gt;
          &lt;/head&gt;
          &lt;body&gt;
              &lt;form method="post" action="send_mail.php" enctype="multipart/form-data"&gt;
              To : &lt;input type="text" name="mail_to"&gt; &lt;br/&gt;
              Subject :   &lt;input type="text" name="mail_sub"&gt;
             &lt;br/&gt;
               Message   &lt;input type="text" name="mail_msg"&gt;
               &lt;br/&gt;
              File: &lt;input type="file" name="file" &gt;
              &lt;br/&gt;
                  &lt;input type="submit" value="Send Email"&gt;
  
              &lt;/form&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>and </p>
  
  <p>send_mail.php</p>
  
  <pre><code>      &lt;?php
  
          $mailto = $_POST['mail_to'];
          $mailSub = $_POST['mail_sub'];
          $mailMsg = $_POST['mail_msg'];
         require 'PHPMailer-master/PHPMailerAutoload.php';
         $mail = new PHPMailer();
         $mail -&gt;IsSmtp();
         $mail -&gt;SMTPDebug = 0;
         $mail -&gt;SMTPAuth = true;
         $mail -&gt;SMTPSecure = 'ssl';
         $mail -&gt;Host = "smtp.gmail.com";
         $mail -&gt;Port = 465; // or 587
         $mail -&gt;IsHTML(true);
         $mail -&gt;Username = "acc.ldevera@gmail.com";
         $mail -&gt;Password = "accountsamplepassword";
         $mail -&gt;SetFrom("acc.sample@gmail.com");
         $mail -&gt;Subject = $mailSub;
         $mail -&gt;Body = $mailMsg;
         $mail -&gt;AddAddress($mailto);
          $mail-&gt;AddAttachment('pdf_files/', 'reservation.pdf');
  
  
         if(!$mail-&gt;Send())
         {
             echo "Mail Not Sent";
         }
         else
         {
             echo "Mail Sent";
         }
  
      ?&gt;
  </code></pre>
  
  <p>Please help me with my problem, Thanks!</p>