Reputation: 391
I have a web application made with Symfony 2.4 and I use SwiftMailer to send emails.
I use like mailer transport sendmail.
When user send an email, I don't receive this email. But If I do in command line:
$php app/console swiftmailer:spool:send --env=prod
I receive all emails.
¿What can I do?
Thanks a lot!
----Edit----
I have removed all references to spool in my config file, but the problem persist.
----Edit 2----
Config.yml
mailer_transport: sendmail
mailer_host: ****
mailer_user: *****
mailer_password: ****
Upvotes: 2
Views: 4244
Reputation: 10603
Delete the spool line from your configuration (parameters.yml i believe? I've never used symfony so i'm interpreting the docs).
Once you've deleted any mention of the spool from your config, it should stop spooling and send immediately.
Having said that, the reason for spooling is so that it sends the email at the end of the execution of the request so that you don't have the performance hit (slowed down requests), probably via a shutdown function... the only reason this function wouldn't execute and therefore your email's not send, is if the script is ending early (i.e. a die/exit or uncatched exception), so you may want to look at addressing the root cause rather than patching around it.
Edit: manual flush (fund this on a command line script example, i've edited it to what i think should make it work for you....)
// now manually flush the queue
$container = $this->getContainer();
$mailer = $this->get('mailer');
$spool = $mailer->getTransport()->getSpool();
$transport = $container->get('swiftmailer.transport.real');
$spool->flushQueue($transport);
http://symfony.com/doc/current/cookbook/console/sending_emails.html
Upvotes: 2