I'm trying to write a simple script to check and read POP3 email, but I'm not getting very far.
First I tried to use the little scripts in the "IMAP Mail Reading With PHP3"
(http://www.phpbuilder.com/columns/musone19990207.php3) article here at PHP Builder. Now, I know my web server, hosted at phpwebhosting.com, doesn't use IMAP, so I swapped out the IMAP-specific stuff in favor of POP3 stuff. I called the file "inbox.php" and the code looked like this, with my personal stuff marked as [SOMETHINGINCAPITALLETTERS]:
<?php
$MAILSERVER="{pop3_server:110/pop3}";
$link=imap_open([MYSERVER],$login,$pass);
$headers=imap_headers($link);
for($x=1; $x < count($headers); $x++) {
$idx=($x-1);
echo "<a href=\"view.php3?num=$x\">$headers[$idx]</a><br>";
}
?>
However, when I pass my login form on to inbox.php, I get this:
Warning: Couldn't open stream mail(server) in /home/[MYLOGIN]/www/mail/inbox.php on line 4
Warning: Unable to find stream pointer in /home/[MYLOGIN]/www/mail/inbox.php on line 5
Frankly, I have no clue what that means.
So, baffled and unhappy, I decided to use someone else's class to jumpstart my script. I found a fine POP3 class here: http://www.thewebmasters.net/php/POP3.phtml. I tested it with the following code, changing my login form to reflect its variables:
include("class.POP3.php3");
$pop3 = new POP3();
if(!$pop3->connect("[MYMAILSERVER]",110)) {
echo "Ooops $pop3->ERROR <BR>\n";
exit;
}
$Count = $pop3->login($login,$pass);
if( (!$Count) or ($Count == -1) ) {
echo "<H1>Login Failed: $pop3->ERROR</H1>\n";
exit;
}
// ONLY USE THIS IF YOUR PHP VERSION SUPPORTS IT!
register_shutdown_function($pop3->quit());
if ($Count < 1) {
echo "Login OK: Inbox EMPTY<BR>\n";
} else {
echo "Login OK: Inbox contains [$Count] messages<BR>\n";
}
Then I get this error message:
POP3: premature NOOP OK, NOT an RFC 1939 Compliant server
Could someone translate these error messages for me? I know my mail server's running qmail, if that makes any difference. And I haven't had any problems logging on to my server with services like mail2web.com. What am I doing wrong? Thanks.