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

PHP
PHP 七大优势分析
PHP n个不重复的随机数生成代码
php addslashes 函数详细分析说明
PHP 文件上传功能实现代码
PHP 超链接 抓取实现代码
PHP 网页过期时间的控制代码
PHP HTML代码串 截取实现代码
php 过滤危险html代码
PHP 彩色文字实现代码
通过PHP CLI实现简单的数据库实时监控调度
php mysql Errcode: 28 终极解决方法
连接到txt文本的超链接,不直接打开而是点击后下载的处理方法
phpmyadmin MySQL 加密配置方法
PHP 上传文件大小限制
php 多个submit提交表单 处理方法
PHP 页面跳转到另一个页面的三种方法方法总结
php 执行系统命令的方法
程序员编程十条戒律
php 论坛采集程序 模拟登陆,抓取页面 实现代码
PHP 程序授权验证开发思路

PHP 中的 pop3邮件收取一例


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