title: reading inbox with IMAP is not very fast
body: <p>I am using IMAP to read my last 3 unseen emails.
  I am using php. The email provider is fastmail.
  I use the following approach.
  I get the emails where $d is yesterday.</p>
  
  <pre><code>$s = 'SUBJECT "New email from " SINCE "'.$d.'" UNSEEN';          
  $emails = imap_search($this-&gt;conn,$s); 
  </code></pre>
  
  <p>$emails is an array of email ids.
  I loop over them like so:</p>
  
  <pre><code>foreach ($emails as $index =&gt; $i) {
      $message   = imap_body($this-&gt;conn, $i) . '&lt;br&gt;';
      $overview  = imap_fetch_overview($this-&gt;conn, $i, 0);
      $structure = imap_fetchstructure($this-&gt;conn, $i);
  
      if (!empty($overview[0])) {
          $subject = $overview[0]-&gt;subject;
      }
  
      //from this point i get some html and i just process it.
      $mes = imap_body($this-&gt;conn, $i);
  }
  </code></pre>
  
  <p>How can i make the whole process faster? Any ideas?
  I am not an expert in IMAP.
  Is there any way that i can just get the text body, and not the rest of the email?</p>
  
  <p>Thanks in advance!</p>