simoneroma85
simoneroma85

Reputation: 1

CakePhp Could not send email

When i try to send message in cakephp or register a new user i receive:

Could not send email.

Error: An Internal Error Has Occurred. Stack Trace

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)

i'm new in CakePhp and i edit this file, in app/Config/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',
);

also edit lib/Cake/Network/Email/CakeEmail.php

    protected $_transportName = 'Smtp';

and edit lib/Cake/Network/Email/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;
}

Please help me... everithing work, not email or message. If u want to recreate the error you could register on my site http://bbcd.bio.uniroma1.it/eventi/

Thx everyone answer me.


Here the Code:

                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;
                }

Upvotes: 0

Views: 3285

Answers (1)

simoneroma85
simoneroma85

Reputation: 1

Finally...i solve it. I made a mistake, forgot to configure pear mail, finally i'm able to send email with smtp. If anyone want help, can see this tutorial: http://www.youtube.com/watch?v=dKO4MfOpDVs

Thx all for answer.

Upvotes: 0

Related Questions