here it is in case anyone else finds it helpful:
$mbox=imap_open('{mail.mymaildomain.com:110/pop3}INBOX', '[email protected]', 'mypassword') or die('POP3 connection failed');
$mails=imap_num_msg($mbox);
echo $mails." new mails arrived\n";
for ($i=1; $i<=$mails; $i++)
{
$mbody=imap_body($mbox, $i);
$lines=explode("\n", $mbody);
foreach ($lines as $tmp)
{
$tmp=trim($tmp);
if (empty($tmp)) { continue; }
echo "BODY[".$tmp."]\n";
}
# imap_delete($mbox, $i);
}
#imap_expunge($mbox);
imap_close($mbox);
?>
basically i set up a new pop box, and a cron to run this script every 10 minutes.
edit: i tested the delete/expunge commands too and it works fine, thanks