·您的位置: 首页 » 资源教程 » 编程开发 » PHP » pop mail 类 很简单的功能(自家用)

pop mail 类 很简单的功能(自家用)

类别: PHP教程  评论数:0 总得分:0

<?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='rn';
  //$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();

时间仓促,没有注释,望见谅!

-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1