popmail类很简单的功能(自家用)_PHP
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了popmail类很简单的功能(自家用)_PHP,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1916字,纯文字阅读大概需要3分钟。
内容图文
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();
时间仓促,没有注释,望见谅!
内容总结
以上是互联网集市为您收集整理的popmail类很简单的功能(自家用)_PHP全部内容,希望文章能够帮你解决popmail类很简单的功能(自家用)_PHP所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。