Home >Backend Development >PHP Tutorial >Electronic Post Office PHP Application - Collecting POP3 Mail (2)_PHP Tutorial

Electronic Post Office PHP Application - Collecting POP3 Mail (2)_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:31:291112browse


The class for receiving emails in POP3 has been introduced in detail in the previous article. Let’s take a look at how to apply this class:
 
 

include("pop3.inc .php(as the current mainstream development language)");
 
 $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 "Total ".$rec->messages." letters, total ".$rec->size." byte size
";
 
 
 
 if ($ rec->messages>0)
 
 {
 
 if (!$rec->listmail()) die($rec->err_str);
 
echo "There are 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 "The content of the email header:
";
 
 for ($i=0 ;$i
head);$i++) 
echo htmlspecialchars($rec->head[$i])."
";
 
 echo "Email text:
";
 
 for ($i=0;$i
body);$i++) 
 echo htmlspecialchars ($rec->body[$i])."
";
 
 }
 
 $rec->close();
 
 ?>
 
 If you set debug in the pop3 class to true If so, you can also see how the program communicates with the pop3 server, which is more intuitive for the program being debugged.
 
 
Summary From the above. In this example, we can see that php
(as the current mainstream development language) is really a very powerful tool for website development, but we can also feel that php (as the current mainstream development language) Mainstream development language) As a hybrid language, its object-oriented development still has many regrettable aspects compared with other tools such as Java. There are also many implementations of this pop class. If there is any need for improvement, colleagues are welcome to provide guidance

http://www.bkjia.com/PHPjc/509084.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509084.htmlTechArticleThe class of POP3 receiving emails has been introduced in detail in the previous article. Let’s take a look. How to use this class: include("pop3.inc.php (as the current mainstream development language...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn