views:

33

answers:

1

Hi guys, I'm working with zend framework and recently had terrible issue swith my code. Actually I'm developing a webfront for emails and users enter their mail server details and are able to check on their email via my system.

The issue is that whenever I would try to connect to a mailserver my system just dies out sometimes and instead I am prompted to download the index page i.e the page being run - of course I'd end up with an empty page but thats not supposed to be happening.

I did some checking and found that the code is dying in the Zend_Mail_Protocol_Imap class in the connect function and that too at the code which says:

$this->_socket = fsockopen($host, $port, $errno, $errstr, self::TIMEOUT_CONNECTION);

on line 94 in the link posted.

What do I do here how do I set up a check to work around this atleast find out whats happened here :(

You can check out from a screenshot what I'm seeng here: alt text

EDIT==================

My code which I'm actually running [I'm just using the libraries here] is :

$mailConfig = array('host' => $current_dept->incoming_server,
'port'=>$current_dept->incoming_port,                       'folder'=>$mbox_name,
'user' =>$current_dept->email,
'password' =>$current_dept->email_psd);


$mailConfig['ssl'] ='ssl';

try{
    if($mail)
        unset($mail);

    $mail = new Zend_Mail_Storage_Imap($mailConfig);


    }catch (Zend_Mail_Exception $e) {
        var_dump($e);
        exit;
    }

The fsockopen is in the Zend_mail_protocol_Imap class which is subsequently invoked within the constructor of the zend_mail_storage_imap class.

despite being enclosed in a try catch block its not even running the try catch block.

Plus the file prompted for download is just an empty file with the same name as the php file being executed.

EDIT ==========================

I've found the problem - for some reason an exception is being thrown and its nested really deep. But what I don't understand is this behavior of prompting to download a file instead of outputting any form of error message or so.

A: 

Firstly, Whats actually in the PHP file thats forced to be downloaded.

also, the zend code is not the problem i think.

In your Controller where you run $???->connect(); try doing this

try
{
    $mail->connect();
}cache(Zend_Mail_Protocol_Exception $Exception)
{
     die("Debug: " . $Exception->toString());
}

To see if that has any affect ?

RobertPitt
Actually I had traced till the point in code which was last run before it died out.. lemme get back in a minute on this..
Ali
CHeck my updated question!
Ali
Exception isn't even thrown here...I'm running out of ideas..
Ali
hmm, Ok try do some debugging by doing `echo 'inTry';` within the try to make sure the code is in there. also does the $mail dump out? with var_dump
RobertPitt
Nothing is echoed though unfortunately - however I have a log function that writes to a file. The try is being entered as my log function within that try block is being run but nothing goes further.
Ali
The error logs are not showing anything here... and I ahve set error reporting to E_ALL. whats happeneing
Ali
I've traced it further and found out that the connection is getting closed somehow when the _nextLine function is called in the same class.
Ali