Closed ahmadrabie closed 8 years ago
Have you tried this? http://symfony.com/doc/current/cookbook/console/sending_emails.html#using-memory-spooling
Basically this worked when I tried it (Assuming you are using ContainerAwareJob):
$mailer = $this->getContainer()->get('mailer');
$spool = $mailer->getTransport()->getSpool();
$transport = $this->getContainer()->get('swiftmailer.transport.real');
$spool->flushQueue($transport);
I found another solution - unspooling memory spool manually by custom event: https://stackoverflow.com/questions/29802225/swiftmailer-not-sending-immediately/51730638#51730638
Based on Symfony's SwiftMailer doc about using spool when you're using spool option (e.g.
memory
) emails will be sent onkernel.terminate
event.I have a job inside which I'm sending an email using swift mailer which doesn't seem to work but when I turn of
spool
option emails are sent.How do I make sure that Kernel's terminate event is correctly dispatched in a Resque job? Where should I look for this? I'm new to Symfony but maybe we need
$kernel->terminate()
or something somewhere!