当我尝试在cakephp中发送消息或注册我收到的新用户时:
Could not send email.
错误:发生内部错误。 堆栈跟踪
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 / Config / email.php中编辑了这个文件
public $smtp = array(
'transport' => 'Smtp',
'from' => array('simone.zambenedetti@uniroma1.it' => '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 / Cake / Network / Email / CakeEmail.php
protected $_transportName = 'Smtp';
并编辑lib / Cake / Network / Email / SmtpTransport.php
public function config($config = array()) {
$default = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'timeout' => 30,
'username' => 'simone.zambenedetti@uniroma1.it',
'password' => 'enomis58',
'client' => null,
'tls' => false
);
$this->_config = $config + $default;
}
请帮助我...工作,不是电子邮件或消息。 如果你想重新创建错误,你可以在我的网站上注册 http://bbcd.bio.uniroma1.it/eventi/
大家都回答我。
这里的代码:
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;
}
答案 0 :(得分:0)
最后......我解决了。 我犯了一个错误,忘了配置梨邮件,最后我能用smtp发送电子邮件。 如果有人想要帮助,可以看到这个教程: http://www.youtube.com/watch?v=dKO4MfOpDVs
谢谢所有回答。