pop mail 类 很简单的功能(自家用)
<?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();
时间仓促,没有注释,望见谅!
- · PHP.MVC的模板标签系统之模板标签库
- · IIS vs.Apache: 哪个是安全首选
- · 使用PHP批量生成随机用户名
- · 使用PHP批量生成随机用户名
- · 使用PHP生成1000个随机注册码
- · UTF-8转换成GB2312的全处理
- · 旧题新貌:PHP截取中文字符串的问题
- · PHP.MVC的模板标签系统之初识PHP.MVC
- · include的妙用,实现路径加密
- · php扩展学习笔记
- · PHP.MVC的模板标签系统(三)
- · Windows下PHP和Apache的安装与配置
- · PHP.MVC的模板标签系统(二)
- · PHP 链接ACCESS 数据库最简单的方法
- · 加强用户密码保存及检验的安全性
- · 当PHP被禁用的PHP函数:tempnam() 后
- · PHP.MVC的模板标签系统(一)
- · PHP中date函数的选项说明
- · 彻底解决Tomcat 5.0.19中文乱码(过滤器)
- · 天衣无缝:IIS与PHP水火也相容
- · 在PHP.MVC中上传文件
- · 在PHP.MVC中上传文件
- · 表单验证之PHP代码框架
- · PHP在线邮件发送类,通过SMTP来发送
- · php的几个配置文件函数
- · Apache 1.33与PHP 4.4.0配置手记
- · 在IIS里安装PHP的方法
- · Windows下PHP5和Apache的安装与配置
- · 使用PHP往Windows系统中添加用户
- · PHP中几种删除目录的方法
- · PHP实现自动刷数和“灌水”机
- · PHP实现网页自动更新块
- · WINDOWS 2000下使用ISAPI方式安装PHP
- · Tomcat中DataSource的配置方法
- · Windows XP下集成Tomcat与Apache
- · PHP网站中整体防注入方法
- · 非常简单的php模版类--DarasionTemplate
- · 非常简单的php模版类--DarasionTemplate
