我无法发送电子邮件 CakePHP
I can't send email CakePHP
它正在测试我的应用程序,您在其中使用 cakephp 创建了一个网络服务。在测试和调试我的应用程序时,我始终将我的核心值保持为 2。所有对我都有效,是时候尝试所有核心 0 了,除了发送电子邮件外,一切正常。但是通过更改核心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();
这不是最佳解决方案,但绝对适合您。我想您的功能是 sendMail()
,您通过它发送 mail.Try 来执行以下操作:-
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
放在函数的第一行即可完成工作。
它正在测试我的应用程序,您在其中使用 cakephp 创建了一个网络服务。在测试和调试我的应用程序时,我始终将我的核心值保持为 2。所有对我都有效,是时候尝试所有核心 0 了,除了发送电子邮件外,一切正常。但是通过更改核心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();
这不是最佳解决方案,但绝对适合您。我想您的功能是 sendMail()
,您通过它发送 mail.Try 来执行以下操作:-
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
放在函数的第一行即可完成工作。