Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 电子邮件突然每小时才发送一次_Php_Symfony_Swiftmailer - Fatal编程技术网

Php 电子邮件突然每小时才发送一次

Php 电子邮件突然每小时才发送一次,php,symfony,swiftmailer,Php,Symfony,Swiftmailer,我有一个cronjob,它每分钟运行一个命令。该命令执行swiftmailer:spool:send命令: $this->getContainer()->get('project')->runCommand('swiftmailer:spool:send'); 这是runCommand方法: 这项工作进行了很长一段时间,但突然之间,电子邮件每小时发送一次。甚至,如果我手动运行该命令,那么它也不是crontab作业问题。唯一的方法是手动运行以下命令: php应用程序/控制台sw

我有一个cronjob,它每分钟运行一个命令。该命令执行swiftmailer:spool:send命令:

$this->getContainer()->get('project')->runCommand('swiftmailer:spool:send');
这是runCommand方法:

这项工作进行了很长一段时间,但突然之间,电子邮件每小时发送一次。甚至,如果我手动运行该命令,那么它也不是crontab作业问题。唯一的方法是手动运行以下命令:

php应用程序/控制台swiftmailer:spool:send-env=prod

这是立即发送电子邮件的唯一方法

如果我运行:ls-la app/cache/prod/swiftmailer/spool,我可以在那里看到电子邮件,直到发送电子邮件为止。当我手动运行该命令时,我没有收到任何错误,但是电子邮件仍然存在并且没有发送


你知道这里会发生什么吗?

你的symfony命令似乎没有问题,但是你正在使用的SMTP服务器有问题。您的/var/log/mail.log中是否有错误?您正在使用哪个smtp服务器?@VictorHenriquez-mail.log中没有错误。我已经尝试了几个SMPT服务器,所以似乎没有问题。
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");
}