2

我有一个使用 Symfony 2.4 制作的 Web 应用程序,我使用 SwiftMailer 发送电子邮件。

我使用像邮件程序传输sendmail。

当用户发送电子邮件时,我没有收到这封电子邮件。但是如果我在命令行中这样做:

$php app/console swiftmailer:spool:send --env=prod

我收到所有电子邮件。

我能做些什么?

非常感谢!

- - 编辑 - -

我已经删除了配置文件中对 spool 的所有引用,但问题仍然存在。

----编辑2----

配置.yml

mailer_transport: sendmail
mailer_host: ****
mailer_user: *****
mailer_password: ****
4

1 回答 1

2

从您的配置中删除假脱机线(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/cookbook/console/sending_emails.html

于 2014-01-23T09:58:10.240 回答