繁体   English   中英

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

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

我使用cakephp电子邮件组件。 在我的实时服务器中,$ this-> Email-> send()返回成功。 但邮件未收到。 问题是什么?? 我需要找出错误所在? 我的控制器没有任何型号,这可能会对电子邮件造成任何问题?

        $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();

您可以将传递设置为调试以查看消息的输出,以确保一切正常:

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

而且您还需要setFlash('email')来在视图中查看输出:

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

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

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