The popmail class has simple functions (for your own use)

Source: Internet
Author: User
Tags ereg
? 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.