title: Zend_Mail - Fetch IMAP Attachements from GMAIL
body: <p>I habe some trouble with Zend Framework and fetching Attachements from GMAIL. Authentication is handeld by oAuth.</p>
  
  <p>It is no problem to fetch the Mailtext, but i cant fetch the attachement, or better i have no idea how to do it (; </p>
  
  <pre><code>        if ($message-&gt;isMultiPart()) {
  
              $iParts = $message-&gt;countParts();
  
              for ($i = 1; $i &lt; $iParts; $i++) {
                  $part = $message-&gt;getPart($i);
  
                  // ATTACHEMENT?
                  if () {
                      // DO MAIL DOWNLOAD
                  }
  
                  // MAIL TEXT
                  if (strtok($part-&gt;contentType, ';') == 'text/plain') {
                      $encoding = $part-&gt;getHeader('content-transfer-encoding');
                      $contentType = $part-&gt;getHeader('content-type');
                      $content = $part-&gt;getContent();
                      break;
                  } 
              }
  </code></pre>
  
  <p>Header from my mail (removed some details):</p>
  
  <blockquote>
  <pre><code>[delivered-to] =&gt; xxxx@gmail.com
  [received] =&gt; Array
      (
          [0] =&gt; 
          [1] =&gt; 
          [2] =&gt; 
          [3] =&gt; 
      )
  [return-path] =&gt; 
  [received-spf] =&gt; 
  [authentication-results] =&gt; 
  [dkim-signature] =&gt;
  [mime-version] =&gt; 1.0
  [from] =&gt; 
  [date] =&gt; Thu, 30 Aug 2012 17:16:37 +0200
  [message-id] =&gt; 
  [subject] =&gt; ANHANG
  [to] =&gt; 
  [content-type] =&gt; multipart/mixed; boundary=f46d043bd88a9f5d9404c87d2ad5
  </code></pre>
  </blockquote>