我有一个由Symfony 2.4制造的Web应用程序,我使用SwiftMailer发送电子邮件。
我使用的是邮件运输sendmail。
用户发送电子邮件时,我不会收到此电子邮件。但是,如果我在命令行:
$php app/console swiftmailer:spool:send --env=prod
我收到所有电子邮件。
¿我该怎么办?
非常感谢!
----编辑----
我已删除了我的配置文件中的所有引用,但问题仍然存在。
----编辑2 ----
config.yml
mailer_transport: sendmail
mailer_host: ****
mailer_user: *****
mailer_password: ****
从您的配置中删除spool行(parameters.yml我相信?我从未使用过Symfony,所以我正在解释文档)。
您从配置中删除了任何对线轴的提及后,它将停止脱身并立即发送。
话虽如此,因此,载假的原因是在请求执行结束时发送电子邮件,以便您没有性能命中率(请求放慢速度),可能是通过关闭功能。。该功能无法执行,因此您的电子邮件未发送的唯一原因是,如果脚本较早结束(即,死亡/退出或无键的例外),因此您可能需要查看解决根本原因而不是修补它。
编辑:手动齐平(在命令行脚本示例上资助此功能,我已经将其编辑为我认为应该使它适合您的内容....)
// 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/corbook/console/sending_emails.html