0

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?

Nic Wortel
  • 11,155
  • 6
  • 60
  • 79
Manolo
  • 24,020
  • 20
  • 85
  • 130
  • It doesn't look like an issue with your symfony command, but with the SMTP server you are using. Is there any error in your /var/log/mail.log? Which smtp server are you using? – Victor Henriquez May 13 '14 at 09:20
  • @VictorHenriquez - No errors in mail.log. I've tried several SMPT servers, so it doesn't seem to be the problem. – Manolo May 13 '14 at 11:54

0 Answers0