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

PHP
PHP中for循环语句的几种“变态”用法
用PHP与XML联手进行网站开发
PHP程序漏洞产生的原因和防范方法
利用PHP编程防范XSS跨站脚本攻击
使用PHP往Windows系统中添加用户
PHP Shell的编写(改进版)
PHP开发中接收复选框信息的方法
PHP程序加速探索之服务器负载测试
PHP实现首页自动选择语言转跳
十天学会php之第一天
十天学会php之第二天
十天学会php之第三天
十天学会php之第四天
十天学会php之第五天
十天学会php之第六天
十天学会php之第七天
十天学会php之第八天
十天学会php之第九天
十天学会php之第十天
Web开发源代码:PHP生成静态页面的类

PHP 中的 pop3邮件收取一例


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