开发者

Php reading email from pop

this is my code:

  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_num开发者_开发问答ber,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); 

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

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

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.


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜