1

I have function:

public function contact()
{
    $dane = $this->data;
    echo debug($dane);
    $Email = new CakeEmail();
    $Email->from(array(''.$this->data['kontakt']['email'].'' => 'Strefagospodarcza.pl'))
    ->to('contact@mysite.pl')
    ->subject(''.$this->data['kontakt']['temat'].'')
    ->send(''.$this->data['kontakt']['tresc'].'');

}

And beforeFunction in Controller

    function beforeFilter(){
        App::uses('CakeEmail', 'Network/Email');
        $this->Auth->userModel = 'User';
$this->Auth->allow('register','login','step2','TakeId','znajdzUzytkownikow');
    }

I have error:

Error: An Internal Error Has Occurred.

And this type of stack trace:

CORE\Cake\Network\Email\MailTransport.php line 47 → MailTransport->_mail(string, string, string, string, null)
CORE\Cake\Network\Email\CakeEmail.php line 1066 → MailTransport->send(CakeEmail)
APP\Controller\UsersController.php line 477 → CakeEmail->send(string)
[internal function] → UsersController->kontakt()
CORE\Cake\Controller\Controller.php line 486 → ReflectionMethod->invokeArgs(UsersController, array)
CORE\Cake\Routing\Dispatcher.php line 187 → Controller->invokeAction(CakeRequest)
CORE\Cake\Routing\Dispatcher.php line 162 → Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse)
APP\webroot\index.php line 109 → Dispatcher->dispatch(CakeRequest, CakeResponse)

Where is mistake? I can not see it, for me all looks fine :)

Mateusz
  • 49
  • 4

2 Answers2

0

change in app\Config\core.php

//from
Configure::write('debug', 1);
//to
Configure::write('debug', 2);

Then get full error message. Try to avoid one line code is harder to debug when something goes wrong.

put

App::uses('CakeEmail', 'Network/Email');

inside contact function, that's might be the problem.

Powodzenia ;)

Tomasz Ferfecki
  • 1,263
  • 14
  • 22
0

Are you doing this on local server like WAMP? If it is, then you will get this kinds of error. You need to setup your mail server if you wants to test it on local server.

Fazal Rasel
  • 4,446
  • 2
  • 20
  • 31