0
。 堆栈跟踪的CakePHP无法发送电子邮件
CORE\Cake\Network\Email\MailTransport.php line 47 → MailTransport->_mail(string, string, string, string, null)
CORE\Cake\Network\Email\CakeEmail.php line 1066 → MailTransport->send(CakeEmail)
CORE\Cake\Controller\Component\EmailComponent.php line 347 → CakeEmail->send(null)
APP\Plugin\Messages\Controller\MessagesController.php line 158 → EmailComponent->send()
[internal function] → MessagesController->add(string)
CORE\Cake\Controller\Controller.php line 486 → ReflectionMethod->invokeArgs(MessagesController, array)
CORE\Cake\Routing\Dispatcher.php line 187 → Controller->invokeAction(CakeRequest)
CORE\Cake\Routing\Dispatcher.php line 162 → Dispatcher->_invoke(MessagesController, CakeRequest, CakeResponse)
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
我在CakePHP是新的,我编辑这个文件,在app /配置/ email.php
public $smtp = array(
'transport' => 'Smtp',
'from' => array('[email protected]' => 'My Site'),
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '**user**', //hidden
'password' => '**my secret**', //hidden
'client' => null,
'log' => false
//'charset' => 'utf-8',
//'headerCharset' => 'utf-8',
);
还可以编辑的lib /蛋糕/网络/电子邮件/ CakeEmail.php
protected $_transportName = 'Smtp';
和编辑的lib /蛋糕/网络/电子邮件/ SmtpTransport.php
public function config($config = array()) {
$default = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => '[email protected]',
'password' => 'enomis58',
'client' => null,
'tls' => false
);
$this->_config = $config + $default;
}
请帮助我...永恒的工作,而不是电子邮件或消息。 如果你想重新创建错误,你可以在我的网站上注册 http://bbcd.bio.uniroma1.it/eventi/
Thx everyone everyone answer me。
这里的代码:
foreach($usersTo as $userTo) {
if($userTo['User']['notification'] && $userTo['User']['id']!=$this->Auth->user('id')) {
$this->set('message_id', $parent_id);
$this->set('message', $this->request->data['Message']['message']);
$this->Email->reset();
$this->Email->from = Configure::read('evento_settings.systemEmail');
$this->Email->to = $userTo['User']['username'].' <'.$userTo['User']['email'].'>';
$this->Email->replyTo = Configure::read('evento_settings.systemEmail');
$this->Email->return = Configure::read('evento_settings.systemEmail');
$this->Email->subject = __('You have a new message in').' ';
$this->Email->subject.= Configure::read('evento_settings.appName');
$this->Email->delivery = 'mail';
$this->Email->template = 'Messages.new_message';
$this->Email->sendAs = 'both';
$this->Email->send();
//debug($this->Session->read('Message.email'));exit;
}
您忘记了实际发送电子邮件的代码。你是否包装它以捕获$例外? – mark
对不起,这个代码?你能帮助我知道我能找到它吗?以及如何编辑? – simoneroma85
MessagesController.php第158行的代码 – mark