Application examples
POP3 to receive the mail class in the previous article has given you a detailed introduction, below we look at how to apply this class:
Include ("pop3.inc.php");
$host = "pop.china.com";
$user = "Boss_ch";
$pass = "026007";
$rec =new POP3 ($host, 110,2);
if (! $rec->open ()) Die ($rec->err_str);
echo "OPEN";
if (! $rec->login ($user, $pass)) die ($rec->err_str);
echo "Login";
if (! $rec->stat ()) Die ($rec->err_str);
echo "Shared". $rec->messages. " Letter, Total ". $rec->size." BYTE size
";
if ($rec->messages>0)
{
if (! $rec->listmail ()) Die ($rec->err_str);
echo "has the following letters:
";
for ($i =1; $i <=count ($rec->mail_list); $i + +)
{
echo "letter". $rec->mail_list[$i][num]. " Size: ". $rec->mail_list[$i][size]."
";
}
$rec->getmail (1);
echo "Message header content:
";
for ($i =0; $ihead); $i + +)
Echo htmlspecialchars ($rec->head[$i]). "
n ";
echo "Message body:
";
for ($i =0; $ibody); $i + +)
Echo htmlspecialchars ($rec->body[$i]). "
n ";
}
$rec->close ();
?>
If you set debug to True in the POP3 class, you can also see how the program and the POP3 server are talking, which is more intuitive for the program being debugged.
Summary
From the above example we can see that PHP is really a very powerful tool for web development, but can also feel that PHP as a mixed-form language, the face of the development of objects and other tools such as Java, there are still many regrettable places. This pop class implementation also has a lot of need to improve the place, welcome colleagues to guide.
Author: Chen Junqing
If you want to get the complete source code of friends, please contact me: boss_ch@netease.com
Reprint: China Network
http://www.bkjia.com/PHPjc/445245.html www.bkjia.com true http://www.bkjia.com/PHPjc/445245.html techarticle Application Example POP3 the class of receiving mail in the previous article has given you a detailed introduction, below we look at how to apply this class: include (pop3.inc.php); $host =pop.china.c ...