drj00003
drj00003

Reputation: 31

swiftmailer Symfony 2.7 not send email

I'm trying to send a test email in Symfony 2.7.3 with swiftMailer nevertheless it isn't work. I looked many post even if it isn't work. The regular configuration for this often is:

Controller:

            $message = \Swift_Message::newInstance()
            ->setSubject('Mensaje de prueba')
            ->setFrom('[email protected]')
            ->setTo('[email protected]')
            ->setBody(
                $this->renderView(
                    'GuiasDocentesAppBundle:FAQ:plantillaEmail.html.twig',
                    array('correoConsultante' => $correoConsultante)
                ),
                'text/html'
            )
        ;
        $this->get('mailer')->send($message);

Parameters.yml:

{ parameters: { 
    database_host: 127.0.0.1, 
    database_port: null, 
    database_name: databasename, 
    database_user: databaseuser, 
    database_password: databasepassword, 
    mailer_transport: gmail, 
    mailer_host: smtp.gmail.com, 
    mailer_user: [email protected], 
    mailer_password: passwordforprueba1, 
    secret: *******************************, 
    database_driver: pdo_mysql, 
    database_path: null } }

config_dev.yml && config.yml:

swiftmailer:
transport: "%mailer_transport%"
encryption: ssl
auth_mode:  login
host:      "%mailer_host%"
username:  "%mailer_user%"
password:  "%mailer_password%"
spool:     { type: memory }

Actually, I'm in development enviroment but I think it isn't a issue. As you can see, [email protected] is the same in controller and parameters.yml. The right account ([email protected]) have been configured to work with external app without this link I hope somebody can help me. Thanks

Upvotes: 0

Views: 354

Answers (1)

Michał G
Michał G

Reputation: 2302

In symfony 2.7 i got the same issue in one of my app

Solution was to spool emails http://symfony.com/doc/2.7/cookbook/email/spool.html

And send spooled emails via cron ( lame solution - but works for me)

Upvotes: 0

Related Questions