[英]Cakephp 2.x email not working, Why this Error comes
I struck on this problem on many days. 我好几天都在解决这个问题。 Please help.
请帮忙。 I have followed the cakephp documentation.
我已经遵循cakephp文档。 but could not resolve issue.
但无法解决问题。
Could not send email: unknown
Error: An Internal Error Has Occurred.
Following is Configuration emai.php 以下是配置emai.php
<?php
class EmailConfig {
public $default = array(
'transport' => 'Mail',
'from' => 'developer.support@sevenrocks.in',
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
);
public $smtp = array(
'transport' => 'Smtp',
'from' => array('site@localhost' => 'SevenRocks'),
'host' => 'ssl://smtp.sevenrocks.in',
'port' => 465,
'timeout' => 30,
'username' => 'developer.support@sevenrocks.in',
'password' => 'developerofsevenrocks',
'client' => null,
'log' => true,
'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
}
Following is code in controller 以下是控制器中的代码
$email = new CakeEmail();
$email->emailFormat('html');
$email->from(array($from_email => SITE_NAME));
$email->to($to);
$email->subject($subject);
if ($files)
{
$email->attachments($files);
}
if ( !$email->send($content) )
{
return false;
}
First: to debug CakePHP 2x applications search for debug in your app/Config/core.php
and change it to Configure::write('debug', 2);
首先:调试CakePHP 2x应用程序,在
app/Config/core.php
搜索debug并将其更改为Configure::write('debug', 2);
to see the full error message. 查看完整的错误消息。
Second: Some providers may prevent you from sending Mails via PHP directly ( default mail config). 第二:某些提供程序可能会阻止您直接通过PHP发送邮件( 默认邮件配置)。 A better solution may to use the smtp configuration you provided in
email.php
. 更好的解决方案可能是使用
email.php
提供的smtp配置。 To use your smtp configuration change your controller code to: 要使用smtp配置,请将控制器代码更改为:
$email = new CakeEmail('smtp');
$email->emailFormat('html');
$email->to($to);
$email->subject($subject);
For more Info see https://book.cakephp.org/2.0/en/core-utility-libraries/email.html#configuration 有关更多信息,请参见https://book.cakephp.org/2.0/en/core-utility-libraries/email.html#configuration
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.