AnNaMaLaI
AnNaMaLaI

Reputation: 4084

CakePHP email not working properly - how to track the error

I using cakephp email component. In my live server $this->Email->send() return success. but mail is not receiving. what is the problem?? i need to find whats the error ? My controller not have any model this may cause any problem for emails ?

        $this->Email->from     = 'Mysitename <[email protected]';
        $this->Email->to       =  '[email protected]';
        $this->Email->subject  = "This is test";
        $this->Email->template = 'template_name'; 
        $this->Email->sendAs   = 'html'; 

        ob_start();
        if($this->Email->send())
        {
           $this->log(' Mail Success');
        }
        else
        {
          $this->log('Something broke in mail');    
        }
        ob_end_clean();

Upvotes: 1

Views: 1849

Answers (1)

Shaz Ravenswood
Shaz Ravenswood

Reputation: 1835

You can set delivery to debug to see an output of your message to make sure it's fine:

$this->Email->delivery = 'smtp';

And you also need to setFlash('email') to see the output in your view:

echo $this->Session->flash('email');

As far as emailing from a live server goes - there's a very good chance the server or IP is blacklisted and you'll need to get it to pass various checks before your sent messages can be received:

http://www.digitalsanctuary.com/tech-blog/debian/setting-up-spf-senderid-domain-keys-and-dkim.html

Upvotes: 1

Related Questions