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

PHP
php-accelerator网站加速PHP缓冲的方法
特详细的PHPMYADMIN简明安装教程
用PHP读取RSS feed的代码
php自动适应范围的分页代码
PHP+MYSQL 出现乱码的解决方法
php多数据库支持的应用程序设计
推荐学习php sesson的朋友必看PHP会话(Session)使用入门
PHP调用MySQL的存储过程的实现代码
php二分法在IP地址查询中的应用
php IIS日志分析搜索引擎爬虫记录程序
PHP获取网站域名和地址的代码
PHP 数组实例说明
删除数组元素实用的PHP数组函数
PHP去除数组中重复的元素并按键名排序函数
php中的数组操作函数整理
php数组应用之比较两个时间的相减排序
php magic_quotes_gpc的一点认识与分析
php htmlentities和htmlspecialchars 的区别
php过滤危险html代码
PHP Smarty生成EXCEL文档的代码

PHP 中的 pop3邮件收取一例


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 167 ::
收藏到网摘: 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