我无法发送电子邮件CakePHP

时间:2015-06-04 19:30:55

标签: php email cakephp

它正在测试我使用cakephp创建web服务的应用程序。在测试和调试我的应用程序时,我始终保持我的核心价值为2.所有工作对我来说是时候尝试所有的核心0,一切正常,除了发送电子邮件。但是如果核心2被发送则更改核心2而不理解原因。

        $this->Email->to(array('username' => $responsable['User']['email']));
        $this->Email->subject = "Nuevo View";
        $this->Email->from = 'example@example.com';
        $this->Email->template = 'view_notification';
        $this->Email->layout = 'default';
        $this->Email->sendAs = 'html';
        $result = $this->Email->send();

1 个答案:

答案 0 :(得分:1)

这不是最佳解决方案,但它最终会为您服务。我想您的函数是sendMail(),您通过它发送邮件。请尝试如下: -

public function sendMail(){

Configure::write('debug', 2); // just on debug mode specially for this function

$this->Email->to(array('username' => $responsable['User']['email']));
        $this->Email->subject = "Nuevo View";
        $this->Email->from = 'example@example.com';
        $this->Email->template = 'view_notification';
        $this->Email->layout = 'default';
        $this->Email->sendAs = 'html';
        $result = $this->Email->send();

}

注意: - 这是一个示例,因为我不知道您的功能名称以及您在该功能中拥有的其他内容。只需将debug mod line放在函数内的第一行,就可以完成工作。

相关问题