title: PHP: How to determine email attachment's MIME type?
body: <p>I'm using Zend's <code>Zend_Mail_Storage_Pop3</code> to connect to mail server, open an email, and iterate through its attachments. If the attachment is a PDF, I need to download it. At each iteration of each message part, I call the <code>getHeaders</code> and use Regex to determine the mime type of the attachment. In most cases, I get something like this:</p>
  
  <pre><code>["content-type"]=&gt; string(64) "application/octet-stream; name=abc.pdf"
  ["content-transfer-encoding"]=&gt; string(6) "base64"
  </code></pre>
  
  <p>But in some cases, I get something like this:</p>
  
  <pre><code>multipart/mixed; boundary=--boundary_2_1dca5b3b-499e-4109-b074-d8b5f914404a
  </code></pre>
  
  <p>How do I determine the mime type of such attachments?</p>