当前位置: 首页 > 图文教程 > 网络编程 > PHP > pop3邮件收取一例

PHP
Windows下PHP+MySQL+IIS安全平台搭建
e2php搭建Windows下Apache+PHP+MySQL环境
网站图片防被盗的方法汇总
PHP简单学习,保证入门学会
19个PHP模板引擎介绍
PHP菜鸟你是吗?
PHP在国内的应用探讨与分析
PHP+MYSQL网站开发基础知识
PHP解决乱码问题的三种办法
你可能不知道的关于PHP的10件事
PHP基础教程(1):认识PHP
PHP基础教程(2):PHP安装
PHP基础教程(3):PHP语法
PHP基础教程(4):PHP变量
PHP基础教程(5):PHP字符串
PHP基础教程(6):PHP运算符
PHP基础教程(7):PHP If...Else语句
PHP基础教程(8):PHP Switch语句
PHP基础教程(9):PHP数组
PHP基础教程(10):PHP循环

PHP 中的 pop3邮件收取一例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 111 ::
收藏到网摘: n/a

  test_pop3.php

<HTML>
<HEAD>
<TITLE>Test for Manuel Lemos's PHP POP3 class</TITLE>
</HEAD>
<BODY>
<?
require("pop3.php");

$user="user";
$password="passwd";
$apop=0;
$pop3_connection=new pop3_class;
$pop3_connection->hostname="mail.xiaocui.com";
if(($error=$pop3_connection->Open())=="")
{
   echo "<PRE>Connected to the POP3 server &quot;$pop3_connection->hostname&quot;.</PRE>\n";
   if(($error=$pop3_connection->Login($user,$password,$apop))=="")
   {
      echo "<PRE>User &quot;$user&quot; logged in.</PRE>\n";
      if(($error=$pop3_connection->Statistics(&$messages,&$size))=="")
      {
         echo "<PRE>There are <b>$messages</b> messages in the mail box with a total of <b>$size</b> bytes.</PRE>\n";
         $result=$pop3_connection->ListMessages("",0);
         if(GetType($result)=="array")
         {
            for(Reset($result),$message=0;$message<count($result);Next($result),$message++)
               echo "<PRE>Message ",Key($result)," - ",$result[Key($result)]," bytes.</PRE>\n";
             if($messages>0)
            {
                if(($error=$pop3_connection->RetrieveMessage(1,&$headers,&$body,-1))=="")
                {
                  echo "<PRE>Message 1:\n---Message headers starts below---</PRE>\n";
                  for($line=0;$line<count($headers);$line++)
                     echo "<PRE>",HtmlSpecialChars($headers[$line]),"</PRE>\n";
                  echo "<PRE>---Message headers ends above---\n---Message body starts below---</PRE>\n";
                  for($line=0;$line<count($body);$line++)
                     echo "<PRE>",HtmlSpecialChars($body[$line]),"</PRE>\n";
                  echo "<PRE>---Message body ends above---</PRE>\n";
                     
                  }
               }
            &nbs