title: How to read Apple Mail custom IMAP flags with PHP?
body: <p>On Mac Mail, you can set flags Red, Orange, Yellow, Green, Blue, Purple, Gray. On iOS and most other email clients, whichever flag you choose, it ends up Red.</p>
  
  <p>However, the flag colors are kept on other Macs with the same email account, so I assume it must be saved on the IMAP-server. This might be called keyword/custom flags, but I can't find any documentation on it.</p>
  
  <p>This code returns an object containg the IMAP data for the oldest message in the inbox:</p>
  
  <pre><code>$imap = imap_open("{".$server.":143}INBOX", "$email", "$password");
  $header = imap_header($imap, 1);
  echo "".nl2br(var_dump($header))."";
  </code></pre>
  
  <p>If I flag the message, in any color, this part changes, but always "F" no matter what color I choose.</p>
  
  <pre><code>["Flagged"]=&gt; string(1) "F"
  </code></pre>
  
  <p>By using imap_fetch_overview() i get this (0 for no flag, 1 for any flag)</p>
  
  <pre><code>["flagged"]=&gt; int(1)
  </code></pre>
  
  <p>I found this: "these are implemented (by Apple) using 3 IMAP 
  keywords as bits (providing 8 different states although only 7 are used 
  I believe)."
  <a href="http://lists.freron.com/mailmate/2015-January/003578.html" rel="nofollow">http://lists.freron.com/mailmate/2015-January/003578.html</a></p>
  
  <p>But I can't find anything that changes in the data that looks like any bits related to "FLAGGED". Where in IMAP is Mac Mail storing this and how do I read it with PHP?</p>