title: How to feed my imap connection into php-mime-mail-parser
body: <p>I have downloaded php-mime-mail-parser (<a href="https://github.com/php-mime-mail-parser/php-mime-mail-parser" rel="nofollow">https://github.com/php-mime-mail-parser/php-mime-mail-parser</a>) and I'm having a hard time figuring out how to connect my imap connection to the package to parse incoming emails.</p>
  
  <p>I did this a number of years ago successfully, and I can't remember how the heck I did it.</p>
  
  <p>My BROKEN code looks like :</p>
  
  <pre><code> $mbox = imap_open($host, $login, $password) or die("connection errror: " . imap_last_error());
  
  
          $Parser = new PhpMimeMailParser\Parser();
          $Parser-&gt;setStream($mbox);
  // We can get all the necessary data
          $to = $Parser-&gt;getHeader('to');
          $from = $Parser-&gt;getHeader('from');
          $subject = $Parser-&gt;getHeader('subject');
  
          $text = $Parser-&gt;getMessageBody('text');
          $html = $Parser-&gt;getMessageBody('html');
          echo PHP_EOL . "*** $to : $from : $subject : $text" . PHP_EOL;
  // loop the attachments
          $attachments = $Parser-&gt;getAttachments();
  
          if (count($attachments) &gt; 0) {
              //print_r($attachments);
              //exit;
              foreach ($attachments as $attachment) {
                  echo 'Filename : ' . $attachment-&gt;getFilename() . '&lt;br /&gt;'; // logo.jpg
                  echo 'Filesize : ' . filesize($attach_dir . $attachment-&gt;getFilename()) . '&lt;br /&gt;'; // 1000
                  echo 'Filetype : ' . $attachment-&gt;getContentType() . '&lt;br /&gt;'; // image/jpeg
              }
              exit;
          }
          exit;
  </code></pre>
  
  <p>Any help would be appreciatd</p>