简体   繁体   English

CakePHP电子邮件无法正常工作-如何跟踪错误

[英]CakePHP email not working properly - how to track the error

I using cakephp email component. 我使用cakephp电子邮件组件。 In my live server $this->Email->send() return success. 在我的实时服务器中,$ this-> Email-> send()返回成功。 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: 而且您还需要setFlash('email')来在视图中查看输出:

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: 就从实时服务器发送电子邮件而言-服务器或IP很有可能被列入黑名单,并且您需要使它通过各种检查才能接收发送的消息:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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