Php从流行音乐读取电子邮件 [英] Php reading email from pop

查看:185
本文介绍了Php从流行音乐读取电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

  if ($mbox=imap_open( "{" . $mailserver . ":" . $port . "}INBOX", $user, $pass )) 
 {  echo "Connected\n"; 
 } else { exit ("Can't connect: " . imap_last_error() ."\n");  echo "FAIL!\n";  }; 

 if ($hdr = imap_check($mbox)) {
  $msgCount = $hdr->Nmsgs;
  echo "Ci sono ".$msgCount." mail";
} else {
  echo "Failed to get mail";

}

$connection=$mbox;
$result = imap_search($connection, 'UNSEEN');
  $output='';

 foreach($result as $email_number) {

    /* get information specific to this email */
    $overview = imap_fetch_overview($mbox,$email_number,0);
    $message = imap_fetchbody($mbox,$email_number,2);

    /* output the email header information */
    $output.= '<div class="toggler '.($overview[0]->seen ? 'read' : 'unread').'">';
    $output.= '<span class="subject">'.$overview[0]->subject.'</span> ';
    $output.= '<span class="from">'.$overview[0]->from.'</span>';
    $output.= '<span class="date">on '.$overview[0]->date.'</span>';
    $output.= '</div>';

    /* output the email body */
    $output.= '<div class="body">'.$message.'</div>';
  }

  echo $output;

imap_close($mbox); 

问题是脚本太低,我已经返回超过30秒的最大执行时间。

The problem is that the script is too low and I have returned Maximum execution time of 30 seconds exceeded.

我该怎么办?
在我的邮箱中我有很多邮件(20个未读)。

How can I do? In my mailbox I have much mail (20 unread).

问题是,当我做imap_search UNSEEN它返回我所有的邮件,还读邮件。
所以UNSEEN选项不起作用
邮箱是雅虎,我的盒子里有990封邮件,1个未读。
问题是,它返回我990是未读的,但它不是真的...只有1未被读取!

The problem is that when I do imap_search UNSEEN it return me all the mail, also the read mail. So UNSEEN option don't work. The mailbox is yahoo and in my box I have 990 mails and 1 unread. The problem is that it return me that 990 are unreaded but it is not true...only 1 is unreaded!

可能是什么问题?
谢谢。

What may be the problem? Thanks.

推荐答案

您可以修改 max_execution 在PHP中的时间,但是您应该尝试配置文件使您的应用程序如此缓慢。

You can alter the max_execution time in PHP, however you should try to profile what makes your application so slow.

错误信息是否提供任何有用的提示,或者您是否知道IMAP服务器是否缓慢?

Does the error message give you any aditional hints, or do you know if the IMAP server is slow?

这篇关于Php从流行音乐读取电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆