views:

173

answers:

1

Hi guys I'm working on a google apps application. Basically I've set it up so users can add multiple gmail addresses and check on their inboxes in the application. It works fine with a google apps email address however when I add a gmail address it just dies out.

I'm using this code here:

$mail = new Zend_Mail_Storage_Imap($mail_options);

$all_messages = array();

$page = isset($_GET['page'])?$_GET['page']:1;
$limit = isset($_GET['limit'])?$_GET['limit']:20;

$offset = (($page-1)*$limit)+1;

$end = ($page*$limit)>$c?$c:($page*$limit);
for ($i=$offset;$i<=$end;$i++){

    $h2t = new html2text();
    $h2t->set_allowed_tags('<a>');

    if(!$mail[$i])
        break;
    else{
        $one_message = $mail->getMessage($i);
        $one_message->id = $i;
        $one_message->UID = $mail->getUniqueId($i);

        $one_message->parts = array();
        $one_message->body = '';
        $count = 1;
        foreach (new RecursiveIteratorIterator($mail->getMessage($i)) as $ii=>$part) {

            try {
                $tpart = $part;
                //$tpart->_content = '';
                $one_message->parts[$count] =  $tpart;
                $count++;
                // check for html body
                if (strtok($part->contentType, ';') == 'text/html') {
                    $b = $part->getContent();

                    if($part->contentTransferEncoding == 'quoted-printable')
                        $b = quoted_printable_decode($b);

                    $one_message->html_body = $b;
                    $h2t->set_html($b);
                    $one_message->body = $h2t->get_text();
                }

                //check for text body

                if (strtok($part->contentType, ';') == 'text/plain') {
                    $b = $part->getContent();

                    if($part->contentTransferEncoding == 'quoted-printable')
                        $b = quoted_printable_decode($b);

                    $one_message->text_body = $b;

                    $one_message->body = $b;//$part->getContent();
                }

            } catch (Zend_Mail_Exception $e) {
                // ignore
            }

        }

        $all_messages[] = $one_message;

    }
}

No matter what the emails it dies out on retrieving just 2 emails... whats going on here?

+1  A: 

When you are catching the exception log it some where for just do a var_dump, Going through the exception will help to find out the issue easily. Also you can post the exception message here without it answering this question is difficult.

abhinavlal
Its not giving any exception at all which is very strange - I have no idea what to look for in this case...what could be the problem.
Ali
@Ali it isn't strange that you're not seeing an exception since you are catching Zend_Mail_Exception and ignoring it. Try putting the code outside of the try {} catch block and then you may well see some exceptions!
jah
Dang I found out where the issue was - in one of the many umpteen files I was including there was an ini_set command resetting to hide error reporting - errors were being reported prior to the inclusion of that file... got it figured out now...
Ali