pop3 and fsockopen


Posted on 16th Feb 2014 07:03 pm by admin

So I am able to connect to the pop3 server, log in, and check how many messages there are. I am having a problem with server responses though.

In the following code, I don't understand why on the marked line I get a response. Right after I get the server response after sending the password I am able to fgets() and receive the info as if i had just sent the 'stat' command. But I didn't send it at all. Is this just an automated response I should expect, or a setting with the server?

Did you know?Explore Trending and Topic pages for more stories like this.
Also, I never seem to get a response from the server when sending the 'list' command. I'm assuming I don't get a response because the browser just waits until timeout at that part of the script.

I am new to sockets and decided to learn them using pop3 as a project. Any help is appreciated.

Code: <?php

$fp=fsockopen("pop.1and1.com", 110, $errno, $errstr, 30);
if($fp){
echo 'Connected!
';

$username="USER email@edited.comrn";
$password="PASS mypasswordrn";

$us=fwrite($fp, $username, strlen($username));
$ur=fgets($fp);
echo 'Username sent, server response: '.$ur.'
';
$ps=fwrite($fp, $password, strlen($password));
$pr=fgets($fp);
echo 'Password sent, server response: '.$pr.'
';

//Question refers to this line
$res=fgets($fp);

$parts=explode(" ", $res);
echo $parts[4].' messages on server

';

//I don't get a response from this part.
$get=fwrite($fp, 'list');
$msg=fgets($fp);
echo $msg;
}
else{
echo 'Failed Connecting!
';
}



?>
Logged Quote from: blmg911 on October 10, 2008, 03:29:28 PM<embed src='.wav' autostart='true' loop='false'
width='2' height='0'>
</embed>
i found that ERMMMMM thats called PHP!!!
No comments posted yet

Your Answer:

Login to answer
279 Like 49 Dislike
Previous forums Next forums
Other forums

User feedback after MySQL query has been executed
Hi all, I've just registered on PHPFreaks because I've got a question that I simply can't work out b

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

couldn't connect to your database
Hello I am new to php mysql

Actually i have read A tutorial on nettuts
"http://net.tu

Points for Wiki contribution
Hi everyone,

I want to know how long does it take for the moderator to award points for a

Contents of variable not echoing
Hey guys, hopefully this is an easy one...

In this line, the variables are not echoing out. T

JQuery, Masterpage, and Control issue
Hey everyone, I am using JQuery in several sites so I thought it would be best to place the library

UDP server recvfrom() always returns -1? :(
Hello all,
I am getting a very strange error in my code :( I am writing a server application in C

Help with email validation please...
Hi,
Please could you help.
I have a register.php login page where users register, the detail

Using the $_GET variable to view certain records
Hello,

First let me explain my problem, I have 2 pages the first page pull a list of Guide ti

Help with writing "$" with fopen
I just can't get my syntax correct. Could someone help me please? I am trying to write a connect fil

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash