简体   繁体   中英

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 <no-reply@mysite.com';
        $this->Email->to       =  'sample@gmail.com';
        $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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM