We have a cron\'ed PHP script that checks an inbox every ten minutes. The purpose of this script is to handle \"STOP to quit\" functionality for our SMS notification service
use an IO handler to capture the content of the email as a string, split out the headers and then use the php 'mail()' function to send it.
Else if you really want to do this with php-imap,
the php-imap extension is libc-client which is part of the pine email client software figure out the manual steps needed to do it using pine and then look at the c-client calls pine makes to do it. that will give you the steps needed in php.
the c-client documentation is fairly minimal, going to the pine source is the best way to get usage details.
I think you may find that the author of the php extension has "for your convenience or protection" omitted or changed stuff that blocks this path.