Code
<?php
//$socketconn=@fsockopen('pop.sina.com','110');
$socketconn=@fsockopen('pop.tom.com','110');
if($socketconn){
$line=fgets($socketconn,1024);
echo $line;
$command='USER abintest@tom.com'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
$command='PASS 密码'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
$command='LIST'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
$command='TOP 1 0'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
$command='RETR 1'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
echo '<hr/>';
$command='RETR 2'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
//$line=fgets($socketconn,1024);
//echo $line;
while(1){
$contentstring=fgets($socketconn);
if(!$contentstring) break;
if(substr($contentstring,-3)==".\r\n") break;
echo $contentstring;
}
}else echo 'error';
?>
<?php
//$socketconn=@fsockopen('pop.sina.com','110');
$socketconn=@fsockopen('pop.tom.com','110');
if($socketconn){
$line=fgets($socketconn,1024);
echo $line;
$command='USER abintest@tom.com'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
$command='PASS 密码'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
$command='LIST'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
$command='TOP 1 0'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
$command='RETR 1'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
$line=fgets($socketconn,1024);
echo $line;
while($templine=fgets($socketconn)){
if(substr($templine,-3)==".\r\n") break;
echo $templine;
}
echo '<hr/>';
$command='RETR 2'."\r\n";
echo '<br/>'.$command.'<br/>';
fputs($socketconn,$command);
//$line=fgets($socketconn,1024);
//echo $line;
while(1){
$contentstring=fgets($socketconn);
if(!$contentstring) break;
if(substr($contentstring,-3)==".\r\n") break;
echo $contentstring;
}
}else echo 'error';
?>
利用socket~