title: Using Mail_Mime to send attachment to GMail, receiving "noname" attachment
body: <p>I've got a pretty simple website form that can take attachments. It sends to a gmail address using gmail's smtp. Everything is working great except that the file arrives as "noname" - no filename or extension. If you download the attachment and rename it with the correct filename, the file opens just fine.</p>
  
  <p>I've tried adding more arguments to addAttachment() such as the filetype and the filename, but they don't show up in the email. When I click on "Show Original" in gmail, this is all I see in the attachment section (they don't change at all, no matter what arguments I use):</p>
  
  <pre><code>Content-Transfer-Encoding: base64
  Content-Type: application/octet-stream
  Content-Disposition: attachment
  </code></pre>
  
  <p>Here is the relevant part of my code:</p>
  
  <pre><code>require_once 'Mail.php';
  require_once 'mime.php';
  
  $ToEmail = '***@***.com'; 
  $EmailSubject = '*** contact form';
  $Filename = basename($_FILES['uploaded_file']['name']);
  
  $host = "ssl://smtp.gmail.com";
  $port = "465"; 
  $username = "***@***.com";
  $password = "***";
  
  $MESSAGE_BODY = "Blah blah blah";
  
  $Uploads_folder = "../uploads/";
  $Filepath = $Uploads_folder.$Filename;
  $tmp_path = $_FILES["uploaded_file"]["tmp_name"];
  
  if(is_uploaded_file($tmp_path)) {
      if(!copy($tmp_path, $Filepath)) {
          echo 'Sorry, there was an error in uploading the file. Please go back and try  again.';
          exit();
      }
  }
  
  $headers = array ('From' =&gt; $username,
      'To' =&gt; $ToEmail,
      'Subject' =&gt; $EmailSubject);
  
  $mime = new Mail_mime();
  $mime-&gt;setHTMLBody($MESSAGE_BODY);
  $mime-&gt;addAttachment($Filepath);
  
  $body = $mime-&gt;get();
  $headers = $mime-&gt;headers($headers);
  
  $smtp = Mail::factory('smtp',
      array ('host' =&gt; $host,
          'port' =&gt; $port,
          'auth' =&gt; true,
          'username' =&gt; $username,
          'password' =&gt; $password));
  
  $mail = $smtp-&gt;send($ToEmail, $headers, $body);
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>