Raphael Alves
Raphael Alves

Reputation: 55

Symfony swiftmailer in production environment

I have a problem for sending mails with Swiftmailer in Symfony2. Let me explain it: when I go to my website with the app_dev.php, I could send messages, there is no problem (also, when I write $kernel = new AppKernel('prod', true); in app.php).

So, I don't understand why this works in dev and not in prod.

Here is my configuration files:

parameters.yml:

mailer_transport: smtp
mailer_host: ****.ovh.net
mailer_username: [email protected]
mailer_password: ****
mailer_port: ****

config.yml:

swiftmailer:
transport: "%mailer_transport%"
host:      "%mailer_host%"
username:  "%mailer_username%"
password:  "%mailer_password%"
port:      "%mailer_port%"
spool:     { type: memory }

And this is the php code, but I think there is no problem with it because as I said there is no problem in dev mode.

$message = \Swift_Message::newInstance() -> setSubject('Test')
         -> setFrom('[email protected]')
         -> setTo($user -> getMail())
         -> setBody('Test');
$this -> get('mailer') -> send($message);

Thank you very much if you know where is the problem.

Upvotes: 2

Views: 2781

Answers (1)

George
George

Reputation: 1499

If something worked in dev, but not prod try manually deleting the prod cache directory and re-installing and dumping assets again. Review this checklist from the docs.

Upvotes: 1

Related Questions