What I am observing is that the newest message is not read. Sometimes gmail has to be refreshed to read the latest message that has just arrived.
Not sure if there is any method that will do a refresh of the gmail account first ...
Comment on Re: How do I read messages from my gmail account
Are you saying that the unread message has arrived since the $server->select('Inbox') call was issued? If so, you may need to call $server->status('Inbox') to refresh the messages.