CakeEmail depuis Vagrant

Par limtchuck, il y a 11 ans


Je n'arrive pas à envoyer des emails avec la fonction CakeEmail, j'ai l'erreur suivante ;

Error: An Internal Error Has Occurred.
Stack Trace
    CORE/Cake/Network/Email/MailTransport.php line 51 ? MailTransport->_mail(string, string, string, string, null)
    CORE/Cake/Network/Email/CakeEmail.php line 1150 ? MailTransport->send(CakeEmail)
    APP/Controller/UsersController.php line 32 ? CakeEmail->send()
    [internal function] ? UsersController->signup()
    CORE/Cake/Controller/Controller.php line 490 ? ReflectionMethod->invokeArgs(UsersController, array)
    CORE/Cake/Routing/Dispatcher.php line 191 ? Controller->invokeAction(CakeRequest)
    CORE/Cake/Routing/Dispatcher.php line 165 ? Dispatcher->_invoke(UsersController, CakeRequest)
    APP/webroot/index.php line 108 ? Dispatcher->dispatch(CakeRequest, CakeResponse)

Ma config Mail :

class EmailConfig {
    public $default = array(
        'transport' => 'Mail',
        'from' => 'local@dev.com',
        'charset' => 'utf-8',
        'headerCharset' => 'utf-8',
    );
}

Et ma Fonction :

App::uses('CakeEmail', 'Network/Email');
                $cakeMail = new CakeEmail('default');
                $cakeMail->to($this->request->data'User']'mail']);
                $cakeMail->subject('Inscription à Cake');
                $cakeMail->template('signup');
                $cakeMail->viewVars($this->request->data'User'] + array('token' => $token, 'id' => $this->User->id));
                $cakeMail->emailFormat('text');
                $cakeMail->send();

J'utilise une machine virtuelle avec Vagrant et je ne sais pas trop ce que je dois faire :/..

Merci de votre aide

5 réponses

amethyste, il y a 11 ans

refais ton config.yaml en incluant mailcatcher et lance un "vagrant provision" dans la console

ou alors tu installes manuellement un server de mail genre Postfix

limtchuck, il y a 11 ans

J'ai déjà mailcatcher, mais je ne catch aucun mail.. Ils ne partent même pas :/

Romano83, il y a 11 ans

Salut,
je me permets de remonter le topic car j'ai la même erreur lorsque j'essaie d'envoyer un mail.
As-tu trouvé une solution au problème ?

ker0x, il y a 11 ans

Dans la configuration de l'email, essaye de mettre ça :

class EmailConfig {
    public $default = array(
        'transport' => 'Smtp',
        'from' => array('local@dev.fr' => 'Local'),
        'host' => '127.0.0.1',
        'port' => 1025,
        'timeout' => 30,
        'log' => false,
        'charset' => 'utf-8',
        'headerCharset' => 'utf-8',
    );
}
Romano83, il y a 11 ans

Ca marche nickel GyZmO !

Merci à toi ;)