? PhpclasspopMail {var $ usersanshi0815@tom.com; var $ pwd1234; var $ popFp; var $ msg; var $ welcome to use Sanshi pop to receive emails !; FunctionpopMail ($ popHostpop.tom.com, $ popPort110) {$ this-msgarray (); $ this-msg [] $ this-welcome; if (
Class popMail
{
Var$ User = 'sanshi0815 @ tom.com';
Var $ pwd = '20140901 ';
Var $ popFp;
Var $ msg;
Var $ welcome = 'welcome to use Sanshi pop to receive emails! ';
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 ";
}
}
?>
Use
$ Pop = new popMail ();
$ Pop-> init ();
Time is too short and there is no comment. sorry!