All,
I have this code:

<?php 

$fp=fsockopen("pop.secureserver.net", 995, $errno, $errstr, 30); 
if($fp){ 
    echo 'Connected!<br>'; 

$username="USER email@email.com\r\n"; 
$password="PASS password\r\n"; 

$us=fwrite($fp, $username, strlen($username)); 
$ur=fgets($fp); 
if(!$ur){ 
echo "The username didn't send>"; 
} 
echo 'Username sent, server response: '.$ur.'<br>'; 
$ps=fwrite($fp, $password, strlen($password)); 
if(!$ps){ 
echo "The password didn't send<br>"; 
} 
$pr=fgets($fp); 
echo 'Password sent, server response: '.$pr.'<br>'; 

$res=fgets($fp); 
$parts=explode(" ", $res); 
echo $parts[4].' messages on server<br><br>'; 

$cmd="LIST\r\n"; 
$get=fwrite($fp, $cmd, strlen($cmd)); 
$msg=fread($fp, 8192); 
echo '<pre>'.$msg.'</pre>'; 

$cmd="RETR 1\r\n"; 
$get=fwrite($fp, $cmd, strlen($cmd)); 
$msg=fread($fp, 8192);  //This is only retrieving the first line it seems.  The server 'should' have sent an entire message worth of data. 
echo '<pre>'.$msg.'</pre>'; 
} 
else{ 
    echo 'Failed Connecting!<br>'; 
} 
fclose($fp); 
?>

However, it won't send the username/password to authenticate to the server. Any ideas why?

Thanks in advance.

    what error is being returned?

    more than likely you'll need to send an 'ehlo' or 'helo' command first to the server to initiate the sequence

      Thanks, any examples you could provide? Sorry, new to the socket game...

        fwrite($fp, "HELO\r\n");
        //OR
        fwrite($fp, "EHLO\r\n");
        

        i also see no need to add strlen($var) to the socket write for username and password

          fwrite($fp, "EHLO\r\n"); 
          fwrite($fp, "AUTH LOGIN\r\n"); 
          fwrite($fp, "USER email@email.com\r\n"); 
          fwrite($fp, "PASS password\r\n");
          

          depending on how the server is setup the username and password might need to be ran through [man]base64_encode[/man] first

            $fp=fsockopen("pop.secureserver.net", 995, $errno, $errstr, 30);
            if($fp){
            	echo 'Connected!<br>';
            
            //$username="USER email@email.com\r\n";
            //$password="PASS password\r\n";
            fwrite($fp, "HELLO\r\n");
            //$us=fwrite($fp, $username, strlen($username));
            fwrite($fp, "USER email@email.com\r\n");
            $ur=fgets($fp);
            if(!$ur){
            echo "The username didn't send<br>";
            }
            echo 'Username sent, server response: '.$ur.'<br>';
            //$ps=fwrite($fp, $password, strlen($password));
            fwrite($fp, "PASS password\r\n");
            if(!$ps){
            echo "The password didn't send<br>";
            }
            $pr=fgets($fp);
            echo 'Password sent, server response: '.$pr.'<br>';
            
            $res=fgets($fp);
            $parts=explode(" ", $res);
            echo $parts[4].' messages on server<br><br>';
            
            $cmd="LIST\r\n";
            $get=fwrite($fp, $cmd, strlen($cmd));
            $msg=fread($fp, 8192);
            echo '<pre>'.$msg.'</pre>';
            
            $cmd="RETR 1\r\n";
            $get=fwrite($fp, $cmd, strlen($cmd));
            $msg=fread($fp, 8192);  //This is only retrieving the first line it seems.  The server 'should' have sent an entire message worth of data.
            echo '<pre>'.$msg.'</pre>';
            }
            else{
            	echo 'Failed Connecting!<br>';
            }
            fclose($fp);
            

            Updated it to that and then the output I get is:
            Connected!
            The username didn't send
            Username sent, server response:
            The password didn't send
            Password sent, server response:
            messages on server

            I also updated the variables with my username and password.

              you didnt read my last post, the command isnt "HELLO"... its either "ehlo" or "helo" depending on if it supports enhanced or not

              the easiest way to sort this stuff out is to use telnet from your machine and figure out the command sequence that works and then apply it to your code

              you can find loads of information on google about connecting to and authenticating through SMTP servers using telnet

                On windows

                START -> RUN -> enter "CMD" and hit enter

                Type "TELNET" and hit enter

                Type "o pop.secureserver.net 995" and hit enter

                Once connected type "EHLO" and hit enter, it will spit out all the general stuff it supports

                Type "AUTH LOGIN" and hit enter (your mileage may vary here, it may just take "AUTH" or "AUTH PLAIN")

                To determine if you need to need base64 or not:

                Type "USER youremailaddress" and hit enter

                Type "PASS yourpassword" and hit enter

                If either of those two error then you'll need to base64 encode them here

                Once you pass the authentication then you can do what you need

                  Hmm, strange. When I try and connect through Telnet it doesn't work but when I try and connect through the webpage it works fine. I've also added the POP mailbox on my Iphone and that is how I found the port 995 and how it connects to read my email messages.

                    Also, notice that you are using port 995 which is POP3s (SSL layered)

                    It will be easier for you to connect on port 110 which is unsecured POP

                    So do this:

                    $fp=fsockopen("pop.secureserver.net", 110, $errno, $errstr, 30);
                    if($fp)
                    {
                    //REQUIRES AUTH FIRST 
                    fwrite($fp, "USER email@email.com\r\n");
                    fwrite($fp, "PASS password\r\n"); 
                    fwrite($fp, "EHLO\r\n");
                    }
                    

                    I cant test without a real username and password so itll be up to you to fill in the blanks here once you test in telnet

                      That worked perfectly. This is now my output:

                      Connected!
                      Username sent, server response: +OK <29252.1255445718@p3pop01-24.prod.phx3.secureserver.net>
                      Password sent, server response: +OK
                      messages on server

                      -ERR unimplemented
                      +OK
                      1 1782
                      2 2040
                      3 2043

                      So this shows the bytes of data in the message, is there anyway to actually get the email message?

                      Really appreciate your help.

                        OK so its not implementing EHLO, which is OK

                        To get the first message send the command "retr 1"

                          I thought I could read the message because of:

                              
                          $cmd="RETR 1\r\n"; $get=fwrite($fp, $cmd, strlen($cmd)); $msg=fread($fp, 8192); //This is only retrieving the first line it seems. The server 'should' have sent an entire message worth of data. echo '<pre>'.$msg.'</pre>';

                          Is that what is giving the -ERR unimplemented??

                            post your whole code snippet

                            also, each of your echos from the server should be identifiable (number them or something) so you know what echo/command is generating what/which error

                              Here is the whole code:

                              $fp=fsockopen("pop.secureserver.net", 110, $errno, $errstr, 30);
                              if($fp){
                              	echo 'Connected!<br>';
                              
                              fwrite($fp, "USER email@email.com\r\n");
                              $ur=fgets($fp);
                              echo 'Username sent, server response: '.$ur.'<br>'; 
                              fwrite($fp, "PASS password\r\n");
                              $pr=fgets($fp);
                              echo 'Password sent, server response: '.$pr.'<br>';	
                              fwrite($fp, "EHLO\r\n");
                              $res=fgets($fp);
                              $parts=explode(" ", $res);
                              echo $parts[4].' messages on server<br><br>';
                              
                              $cmd="LIST\r\n";
                              $get=fwrite($fp, $cmd, strlen($cmd));
                              $msg=fread($fp, 8192);
                              echo '<pre>'.$msg.'</pre>';
                              
                              $cmd="RETR 1\r\n";
                              $get=fwrite($fp, $cmd, strlen($cmd));
                              $msg=fread($fp, 8192);  //This is only retrieving the first line it seems.  The server 'should' have sent an entire message worth of data.
                              echo '<pre>'.$msg.'</pre>';
                              }
                              else{
                              	echo 'Failed Connecting!<br>';
                              }
                              fclose($fp);

                                you can get rid of:

                                fwrite($fp, "EHLO\r\n");

                                since it doesnt support ehlo

                                  Ok, so these lines:

                                  	$cmd="RETR 1\r\n";
                                  	$get=fwrite($fp, $cmd, strlen($cmd));
                                  	$msg=fread($fp, 8192);  //This is only retrieving the first line it seems.  The server 'should' have sent an entire message worth of data.
                                  	echo '<pre>'.$msg.'</pre>';
                                  

                                  Give me the output:
                                  +OK 1782 octets

                                  I thought that would actually display the message?

                                    So I updated it to this:

                                    $fp=fsockopen("pop.secureserver.net", 110, $errno, $errstr, 30);
                                    if($fp){
                                    	echo 'Connected!<br>';
                                    
                                    fwrite($fp, "USER email@email.com\r\n");
                                    $ur=fgets($fp);
                                    echo 'Username sent, server response: '.$ur.'<br>'; 
                                    fwrite($fp, "PASS password\r\n");
                                    $pr=fgets($fp);
                                    echo 'Password sent, server response: '.$pr.'<br>';	
                                    
                                    //$res=fgets($fp);
                                    //echo $parts[4].' messages on server<br><br>';
                                    
                                    $cmd="STAT\r\n";
                                    $get=fwrite($fp, $cmd, strlen($cmd));
                                    $msg=fread($fp, 8192);
                                    echo "The stats are:<br>";
                                    echo '<pre>'.$msg.'</pre>';
                                    
                                    $cmd="LIST\r\n";
                                    $get=fwrite($fp, $cmd, strlen($cmd));
                                    $msg=fread($fp, 8192);
                                    echo "The list is:<br>";
                                    echo '<pre>'.$msg.'</pre>';
                                    
                                    $cmd="RETR 1\r\n";
                                    $get=fwrite($fp, $cmd, strlen($cmd));
                                    $msg=fread($fp, 8192);  //This is only retrieving the first line it seems.  The server 'should' have sent an entire message worth of data.
                                    echo "The message is:<br>";
                                    echo '<pre>'.$msg.'</pre>';
                                    
                                    }
                                    else{
                                    	echo 'Failed Connecting!<br>';
                                    }
                                    fclose($fp);

                                    I tried to find out where things were happening and got the following output:
                                    Connected!
                                    Username sent, server response: +OK <5928.1255448469@p3pop01-25.prod.phx3.secureserver.net>
                                    Password sent, server response: +OK
                                    The stats are:
                                    +OK
                                    The list is:
                                    +OK 3 5865
                                    The message is:
                                    +OK
                                    1 1782
                                    2 2040
                                    3 2043

                                    I'm still not seeing the message actually being displayed.

                                      Yes the message should be on the lines following "+OK 1782 octets"

                                        [man]fread[/man]

                                        Reading stops as soon as one of the following conditions is met:

                                        * length bytes have been read
                                        * EOF (end of file) is reached
                                        * a packet becomes available (for network streams)
                                        * 8192 bytes have been read (after opening userspace stream)