PDA

View Full Version : Pop3 and Fsockopen


Hellzone
03-14-2005, 10:18 AM
Hey guys i'm having a little problem with PHP and a pop3 mail server, i've been required to make a fully skinnable webmail client for an associate of mine and initially i've been doing tests do work out how the mail servers work in relation to what i can do with php.

I've written the following code to login to the server and list messages but it only outputs the +OK for authentication and nothing else any idea whats going on?

$fp = fsockopen("pop.phreaker.net", 110, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fputs($fp, "USER username\x0D\x0A");
$buffer .= fread($fp, 4096);
fputs($fp, "PASS password\x0D\x0A");
$buffer .= fread($fp, 4096);
fputs($fp, "LIST\x0D\x0A");
$buffer .= fread($fp, 4096);
fclose($fp);

echo $buffer;
}

and the output is
+OK +OK +OK

and after glancing at the code its quite possible it is only displaying the data from the initial command and nothing else! when using the same code with a different pop server i do get 3 +OK and confirmation of who im logged in as, i also get the server name.

Any idea what im doing wrong?
James

marek_mar
03-14-2005, 03:52 PM
Can't you use the mail (http://www.php.net/imap) functions?

Hellzone
03-14-2005, 11:09 PM
I did loook at that intiatally but it has to be functional on servers where the client may not be able to insert php modules.

James

marek_mar
03-14-2005, 11:19 PM
Tryed php-mailer (http://phpmailer.sourceforge.net/)?

Hellzone
03-15-2005, 08:03 AM
No because i need to make the classes myself (thats what i get paid for lol ) and also it's only for sending.

James