我使用Cakephp 2.6,我在email.php中配置了如下的smtp设置,
public $smtp = array(
'transport' => 'Smtp',
'from' => array('support@mywebsite.com'=> 'MYWEBSITE'),
'host' => 'hostingserver',
'port' => 587,
'username' => 'username',
'password' => 'password',
'client' => null,
'log' => false,
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
在控制器功能
中 $email = "myemail";
$Email = new CakeEmail("smtp");
$Email->helpers('Html', 'Form', 'Text');
$Email->emailFormat('html')
->subject('SUB: Notification')
->to($email)
->from('fromemail', 'MYWEBSITE')
->send('My message');
这是 ERROR 我正在
Internal error occured
Stack Trace
CORE/Cake/Network/Email/SmtpTransport.php line 154 → CakeSocket->connect()
CORE/Cake/Network/Email/SmtpTransport.php line 95 → SmtpTransport->_connect()
CORE/Cake/Network/Email/CakeEmail.php line 1161 → SmtpTransport->send(CakeEmail)
APP/Plugin/Admin/Controller/ClientsController.php line 816 → CakeEmail->send(string)
[internal function] → ClientsController->sendemail()
CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(ClientsController, array)
CORE/Cake/Routing/Dispatcher.php line 193 → Controller->invokeAction(CakeRequest)
CORE/Cake/Routing/Dispatcher.php line 167 → Dispatcher->_invoke(ClientsController, CakeRequest)
APP/webroot/index.php line 118 → Dispatcher->dispatch(CakeRequest, CakeResponse)
如果我缺少配置,我们非常感谢您的帮助。
答案 0 :(得分:0)
出现此问题是因为SSL验证出错 - 正如错误消息所示。理想情况下,您应该设置SSL证书,但您可以禁用ssl证书验证作为替代方案,尽管这样做不太安全。
您试图通过直接添加ssl数组来禁用ssl,但正如this post指出的那样,ssl数组需要包含在上下文数组中,如下所示:
'context'=>array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
)
这解决了我的问题。