title: PHPMailer "Could Not Access File:"
body: <p>I am trying to email a file that exists on my server using PHPMailer. When I run this code, I get "Could not access file" and the email sends without the attachment... what is wrong here??</p>
  
  <pre><code>&lt;html&gt;
  &lt;title&gt;Email Sent!&lt;/title&gt;
  &lt;?php 
          include("menu.php");
          include("sqlconnect.php");
          require_once('../PHPMailer/class.phpmailer.php');
  
          $path = $_POST['path'];
          $filename = $_POST['filename'];
          $newpath = "Library/WebServer/Documents/Inventory/".$path;
  
  define('GUSER', 'xxxxxxx@gmail.com'); // GMail username
  define('GPWD', 'xxxxxxx'); // GMail password
  
  
  function smtpmailer($to, $from, $from_name, $subject, $body) { 
      global $error;
      $mail = new PHPMailer();  // create a new object
      $mail-&gt;IsSMTP(); // enable SMTP
      $mail-&gt;SMTPDebug = 0;  // debugging: 1 = errors and messages, 2 = messages only
      $mail-&gt;SMTPAuth = true;  // authentication enabled
      $mail-&gt;SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
      $mail-&gt;Host = 'smtp.gmail.com';
      $mail-&gt;Port = 465; 
      $mail-&gt;Username = GUSER;  
      $mail-&gt;Password = GPWD;           
      $mail-&gt;SetFrom($from, $from_name);
      $mail-&gt;Subject = $subject;
      $mail-&gt;Body = $body;
      $mail-&gt;AddAddress($to);
      $attachtest = $mail-&gt;AddAttachment($newpath);   
      if(!$mail-&gt;Send()) {
          $error = 'Mail error: '.$mail-&gt;ErrorInfo; 
          return false;
      } else {
          $error = 'Message sent!';
          return true;
      }
  }
  
  smtpmailer('xxxxxxx@me.com', 'xxxxxxxx@gmail.com', 'Name', 'test mail message', 'Hello World!');
  
  ?&gt;
  &lt;/html&gt;
  </code></pre>