Connect to POP server

I’m trying to use fsockopen to connect to a POP server…

ini_set('display_errors', 1);

$server = 'localhost';
$user   = '';
$pass   = 'mypassword';

$pop = fsockopen($server, 110);
echo fgets($pop, 128);

fputs($pop, 'USER ' . $user . "\
echo fgets($pop, 128);

fputs($pop, 'PASS ' . $pass . "\
echo fgets($pop, 128);

The connection seems to be established successfully…

+OK POP3 server ready <4332.1282819482@>

…but then the script goes no further, eventually exceeding the maximum execution time (and increasing this to something stupidly high had no effect either).

I’m running PHP 5.2.6 on Windows Server 2003/IIS6, FWIW.

Any ideas?

I’ve had that issue before with email headers!


Do you have another host you could try run the script on incase it’s your host causing the problems?

Nope, same issue I’m afraid :frowning:

Should possibly have mentioned in my original post that opening a command prompt and connecting and executing the same commands via telnet works fine.

Could you test if you can send using fsockopen?

http://www . mustap . com / phpzone_post_95_sending-email-in-php-the-hac


Turns out I needed to use \r
instead of
at the end of each command.

Thanks for taking the time to help me though, it’s much appreciated :slight_smile:

I’d love to use the IMAP extension but it’s not installed on our server and installing it isn’t really an option :frowning:

Would it be possible for you to use ?
Or do you have to do this all through fsockopen

and if you then add the following to your code?

fputs($pop, “LIST”);
echo fgets($pop);

Just tried it on my personal server and the problem still exists.