title: Useful IMAP header information not showing up
body: <p>I'm using standard IMAP functions to get emails in PHP. I need to keep track of the <code>Message-ID</code> (and <code>References</code> and <code>In-Reply-To</code>) for each message to build threads. Once this system gets deployed, I want users to be able to reply to messages in their mail client to add a message to a thread, but in my web interface, replies can't be attached to the original post because I don't have an <code>In-Reply-To</code> ID from any email headers. I would use <code>In-Reply-To</code> ID to attach their reply to the notification that I sent to them of a new post, but I can't because I can't get the IDs. If I had an <code>In-Reply-To</code> header, messages could be grouped, as there is a thread of IDs connecting them.</p>
  
  <p>Also, I want to be able to reply to any message that the user sends to the server email address if there was an error with their submission or anything like that, in which case I'll need the <code>Message-ID</code> of their message so that I can make that the <code>In-Reply-To</code> ID of the message that I send in reply.</p>
  
  <p>I can't get values for <code>Message-ID</code>, nor <code>In-Reply-To</code> even though they actually have values. (Go to any message in Gmail, click the dropdown menu next to the reply button, hit "show original", and you will see that all of the header information that is missing for me when I call the IMAP functions is actually there, as though Gmail doesn't want to give out that information to IMAP servers.)</p>
  
  <p>I've tried a variety of calls that supposedly get the header information (<code>imap_headerinfo</code>, <code>imap_fetchheader</code>, <code>imap_fetch_overview</code>), but they all return the array of sparse values for the header info that I don't need. After executing</p>
  
  <pre><code>$this-&gt;mbox = imap_open('{imap.gmail.com:993/imap/ssl}', $email, $password);
  </code></pre>
  
  <p>I can get only a few useful values out of the header with any of these calls:</p>
  
  <pre><code>imap_header($this-&gt;getImapStream(), "1");
  imap_fetch_overview($this-&gt;getImapStream(), "1");
  imap_fetchheader($this-&gt;getImapStream(), "1");
  </code></pre>
  
  <p>I can see stuff like <code>Subject</code>, <code>To</code>, <code>Reply-To</code>, and other header values, and they are all accurate, but <code>Message-ID</code>, <code>References</code>, <code>In-Reply-To</code>, and other valuable header information is largely absent (rather, the array values that represent them are empty in every case).</p>
  
  <p>I can almost guarantee that the problem isn't with the code itself, as I can see some values in the headers, and I can successfully retrieve the bodies of messages; it's simply as though Google is filtering what header information I can see.</p>
  
  <p><sub>You may notice that I have the exact same question as on <a href="https://stackoverflow.com/questions/7968405/getting-the-value-of-message-id-from-gmail-imap-with-php">this page</a>, but it was suggested that I make my own question, so that's what I've done.</sub></p>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>If somebody can give me a way to reply to messages from my server without needing to retrieve the <code>Message-ID</code> of the message to which I'm replying, that'd be equally awesome.</p>
  
  <hr>
  
  <h2>EDIT 2</h2>
  
  <p>I listed the <code>Message-ID</code> from every message in my very large inbox and, from what I can see, about 40% of the IDs actually show up. If I run the same test again, the same messages retain their <code>Message-ID</code>s. I am searching for a pattern among the messages that show the <code>Message-ID</code> but there is very strong evidence for a non-pattern among the types of messages.</p>
  
  <p>Every message, in reality, has a <code>Message-ID</code> (and I have verified this for even the messages whose IDs don't show up with IMAP queries), but IMAP functions only reveal the ID of some of the messages.</p>