开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜