I have a cronjob that runs a command every minute. That command execute a "swiftmailer:spool:send" command:
$this->getContainer()->get('project')->runCommand('swiftmailer:spool:send');
And this is the runCommand
method:
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
...
function runCommand($command, array $options = array())
{
$kernel = $this->container->get('kernel');
$app = new Application($kernel);
$app->setAutoExit(false);
$app->setCatchExceptions(false);
$input = array(
'command' => $command,
'--env' => $kernel->getEnvironment(),
'--quiet' => null);
$appInput = new ArrayInput(array_merge($input, $options));
$statusCode = $app->run($appInput);
if ($statusCode) throw new \Exception("$command exited with an error $statusCode");
}
This worked for a long time, but suddenly, the emails are sent every hour. Even, if I run the command manually, so it is not a crontab job issue. The only way to go is running manually the command:
php app/console swiftmailer:spool:send --env=prod
It's the only way to send the emails instantly.
If I run: ls -la app/cache/prod/swiftmailer/spool
, I can see the e-mails there until the e-mails are sent. I don't get any error when I run manually the command, but again the e-mails are still there and not sent.
Any idea of what can be happening here?