|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
终于学会把表单的数据插入数据库,然后显示出来了,应该说一个程序的雏形已经诞生了。 <?php
class popMail
{
var $user='sanshi0815@tom.com';
var $pwd='1234';
var $popFp;
var $msg;
var $welcome = '接待利用叁石pop 吸收邮件!';
function popMail($popHost='pop.tom.com',$popPort=110)
{
$this->msg = array();
$this->msg[] = $this->welcome;
if ( $this->openPop($popHost,$popPort))
{
$this->msg[] = 'pop server connect success!';
}else{
print_r( $this->msg );
}
}
function checkCommon($com,$msg)
{
echo $cod = empty($com)? $this->getServerMsg() : $this->putServerMsg( $com );
$this->msg[] = ereg( "^\+OK" ,$cod )? $msg : $com .' exec is fauiler!error:'.$cod ;
if( !ereg( "^\+OK" ,$cod ) )
{
echo $cod;
print_r($this->msg);
$this->closeStmp();
exit(0);
}
}
function init()
{
$greeting='';
$rn='\r\n';
//$this->checkCommon('',"connect");
//echo $this->putServerMsg("APOP ".$this->user ." ".$this->pwd.$rn);
// $this->checkCommon("USER ",'user');
echo $this->putServerMsg("USER $this->user".$rn);
echo $this->putServerMsg("PASS $this->pwd".$rn);
print_r( $this->msg );
}
function openPop($popHost,$popPort=110)
{
if( empty($popHost) )
{
$this->msg[] = 'pop host is null!';
return false;
}
if( $fp = fsockopen($popHost,$popPort))
{
$this->popFp = $fp;
//echo $this->getServerMsg();
return true;
}
$this->msg[] = 'pop server connect failure';
return false;
}
function getServerMsg()
{
if( empty( $this->popFp ) )
{
$this->msg[] = 'popFp is null!';
print_r($this->msg);
return false;
}
return fgets( $this->popFp,512);
}
function putServerMsg($msg)
{
if( empty( $this->popFp ) )
{
$this->msg[] = 'popFp is null!';
print_r($this->msg);
return false;
}
if( feof($this->popFp))
{
echo "fp is end !";
return false;
}
fputs( $this->popFp , $msg );
return $this->getServerMsg();
}
function closeStmp()
{
empty($this->popFp) ? '':fclose($this->popFp);
$this->msg[] = "close stmp";
}
}
?>
利用
$pop = new popMail();
$pop->init();
工夫仓皇,没有正文,瞥见谅!
当然你可以把你最基本的功能放出来的时候就放出来,比如放到论坛上,让大家都参与, |
|