Using PHP to implement POP3 Mail (3) _php tutorial

Source: Internet
Author: User
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 ...

  • 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.