NHTorres
NHTorres

Reputation: 1538

I can't send email CakePHP

It was testing my application in which you create a webservice with cakephp. At the time of testing and to debug my application I always kept my core value to 2. All worked for me and it was time to try all the core 0, everything worked except send email. But by changing the core 2 if it is sent and not understand why.

        $this->Email->to(array('username' => $responsable['User']['email']));
        $this->Email->subject = "Nuevo View";
        $this->Email->from = '[email protected]';
        $this->Email->template = 'view_notification';
        $this->Email->layout = 'default';
        $this->Email->sendAs = 'html';
        $result = $this->Email->send();

Upvotes: 1

Views: 421

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72289

It's not the best solution, but it will work definitively for you. I suppose that your function is sendMail() through which you are sending mail.Try to do like below:-

public function sendMail(){

Configure::write('debug', 2); // just on debug mode specially for this function

$this->Email->to(array('username' => $responsable['User']['email']));
        $this->Email->subject = "Nuevo View";
        $this->Email->from = '[email protected]';
        $this->Email->template = 'view_notification';
        $this->Email->layout = 'default';
        $this->Email->sendAs = 'html';
        $result = $this->Email->send();

}

Note:- it's a sample because i don't know your function name and what other things you have in that function. just put that debug mod line at the very first line inside your function and job will done.

Upvotes: 1

Related Questions