ddeboer/imap — pull request #44 by ysramirez (2014-08-11 05:59:04+00:00)
Title: \imap_header dosen't work with UID

http://us1.php.net/manual/en/function.imap-header.php
http://us1.php.net/manual/en/function.imap-headerinfo.php

msg_number
The message number

http://us1.php.net/manual/en/function.imap-msgno.php
imap_msgno — Gets the message sequence number for the given UID

I don't know why PHP dosen't has a way to read the header with the UID but this is the solution.