2
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception'
with message 'Invalid controller specified (error)'  
in C:\xampp\htdocs\zend\library\Zend\Controller\Dispatcher\Standard.php:248 Stack trace:  
 #0 C:\xampp\htdocs\zend\library\Zend\Controller\Front.php(954):
    Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
 #1 C:\xampp\htdocs\zend\library\Zend\Application\Bootstrap\Bootstrap.php(97):
    Zend_Controller_Front->dispatch()
 #2 C:\xampp\htdocs\zend\library\Zend\Application.php(366): 
    Zend_Application_Bootstrap_Bootstrap->run()
 #3 C:\xampp\htdocs\intern\lc.intern\public\index.php(26):
    Zend_Application->run()
 #4 {main} Next exception 'Zend_Controller_Exception'
 with message 'Invalid controller specified (error)'
   #0 C:\xampp\htdocs\zend\library\Zend\Controller\Front.php(954):
    Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
   #1 C:\xampp\htdocs\zend\library\Zend\Application\B
     in C:\xampp\htdocs\zend\library\Zend\Controller\Plugin\Broker.php on line 336

my code for sending mail is as follows:

$mail = new Zend_Mail();
$mail->addTo('myemail@gmail.com', 'my name')
         ->setFrom('myemanil@gmail.com', 'my name')
         ->setSubject('My Subject')
         ->setBodyText('Email Body')
         ->send();

when I remove the last line i.e., send() then it works fine , but to send a mail we require send() :-P

I'm stuck here ...

please help me ...

thanks in advance

kba
  • 19,333
  • 5
  • 62
  • 89
k1r4
  • 25
  • 6

4 Answers4

1

It looks to me like two things happening here:

  1. The send() method is throwing an exception. Since you are not specifying a $transport object, it is attempting to use standard sendmail as a default. It looks like you are using Windows. Do you have sendmail installed? I, too, get exceptions when sending on my local Windows dev environment. Maybe test with an smtp-based transport?

  2. The thrown exception is triggering the error handler, so it is looking for the ErrorController::errorAction(). The message you see is the result of a missing or incorrectly placed ErrorController.

Just thinking out loud.

David Weinraub
  • 14,144
  • 4
  • 42
  • 64
  • you're right sir ! my file is missing and I recognised the problem , but still I have another problem which I posted in the following link: http://stackoverflow.com/questions/8508888/zend-framework-zend-mail-function-error-included-code – k1r4 Dec 14 '11 at 17:30
  • sir , still my mail function is not working sir, I reposted my updated code @ the following link please answer this http://stackoverflow.com/questions/8508888/zend-framework-zend-mail-function-error-included-code .If you need any more details please fell free to ask me ... – k1r4 Dec 15 '11 at 07:37
0

you have to set the default transport for your application. Where you are writing the code, in the constructor of the class, you have to use this.

function __construct() {
    $tr = new Zend_Mail_Transport_Smtp(<your smtp IP address>);
    Zend_Mail::setDefaultTransport($tr);
}

Note: Along with the above code, please check in your php.ini file of your apache server for the following setting. The below option should be uncommented.

extension=php_openssl.dll
prava
  • 3,916
  • 2
  • 24
  • 35
0

First of all, please update to the latest ZF stable branch.

As a quickfix, you should try to replace your code with this :

$mail = new Zend_Mail();
$mail->addTo('myemail@gmail.com', 'my name')
         ->setFrom('myemanil@gmail.com', 'my name')
         ->setSubject('My Subject')
         ->setBodyText('Email Body');
$mail->send(); 

Depending on the ZF version you are using, method chaining could be the problem here.

Justin T.
  • 3,643
  • 1
  • 22
  • 43
  • Hello Sir, thanks for the reply I'm using the latest version of zf ... but what you said didn't work for me ... – k1r4 Dec 14 '11 at 15:03
0

try like this example from my project

  $options = array(
        'auth'     => 'login',
        'username' => 'username@gmail.com',
        'password' => 'password',
        'ssl'      => 'tls',
        'port' => 587
    );
    $mailTransport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $options);
    Zend_Mail::setDefaultTransport($mailTransport);

$m = new Zend_Mail('UTF-8');
$m->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);

    $m->addTo("username@gmail.com");
    $m->setFrom('username2b@gmail.com', 'username');
    $m->setSubject('usertext');
    $errortext = "report";
    $m->setBodyHtml($errortext, 'UTF-8', Zend_Mime::ENCODING_BASE64);
    $m->send();
Bart
  • 495
  • 1
  • 5
  • 16