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

PHP
PHP中的代码安全和SQL Injection防范
PHP数组实例总结及说明
一个php的图片水印的程序
PHP常见漏洞被攻击原因分析
PHP 5.2.8 紧急发布 修复5.2.7严重漏洞
编写安全 PHP 应用程序的七个习惯
PHP中常用的函数库和一些小技巧
PHP安全基础原则与方法
PHP函数速查表
PHP开发语言中的精华和技巧
测试在每个层上对PHP代码进行检查
不同文件构建PHP程序的正确方式
用phpinfo来实现PHP配置统计
更好的构造开发模板 五种常见的PHP设计模式
PHP的十个高级技巧
PHP对文本数据库的基本操作方法
967个函式列表 PHP常用语法速查表
实用:JAVA事件模式下PHP如何实现
针对配置文件 PHP最常用的ini函数
用PHP开发qmail邮件服务器管理系统

PHP 中的 pop3邮件收取一例


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