View Single Post
ישן 06-07-09, 18:09   # 1
possible
חבר בקהילה
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
הודעות: 121

possible לא מחובר  

עזרה| התחברות לGMAIL בעזרת סוקטים

אני מנסה לשלוף אימיילים מPOP3 בעזרת סוקטים אבל אני לא מצליח להתחבר לג'ימייל.
הינה הקוד:
PHP קוד:
<?
// mail server settings
$host="pop.gmail.com";
$port 995;
$user "username";
$pass "password";

// open a client connection
$fp fsockopen ($host$port$errno$errstr);

// if a handle is not returned
if (!$fp)
{
    die(
"Error: could not open socket connection\n");
}
else
{
    
// get the welcome message
      
$welcome fgets ($fp150);
    
// check for success code
    
if (substr($welcome03) == "+OK")
    {
          
// send username and read response
  
fputs ($fp"USER $user\n");
  
fgets($fp50);

          
// send password and read response
          
fputs ($fp"PASS $pass\n");
  
$ack fgets($fp50);

  
// check for success code
  
if (substr($ack03) == "+OK")
  {
        
// send status request and read response
        
fputs ($fp"STAT\n");
      
$status fgets($fp50);
      if (
substr($status03) == "+OK")
      {
            
// shut down connection
    
fputs ($fp"QUIT\n");
            
fclose ($fp);
      }
      
// error getting status
      
else
      {
    die (
"Server said: $status");
      }
  }
  
// auth failure
  
else
  {
      die (
"Server said: $ack");
  }
    }
    
// bad welcome message
    
else
    {
  die (
"Bad connection string\n");
    }

    
// get status string
    // split by spaces
    
$arr explode(" "$status);

    
// the second element contains the total number of messages
    
echo $arr[1] . " messages in mailbox";
}
?>
זה כל הזמן מגיע לחלק של הBad connection string
תודה לעוזרים.
  Reply With Quote