Symfony 2 和 Swiftmailer 不支持文件假脱机

标签 symfony swiftmailer symfony-2.7

我无法让文件假脱机与 Symfony 2 和 Swiftmailer 一起正常工作。

这是我的配置

# Swiftmailer Configuration
swiftmailer:
    transport:      %mailer_transport%
    host:           %mailer_host%
    username:       %mailer_user%
    password:       %mailer_password%
    spool:
        type: file
        path: '%kernel.root_dir%/spool'
    port:           %mailer_port%
    encryption:     %mailer_encryption%
    sender_address: %mailer_sender_address%

当我发送电子邮件时,会在 app/spool/default/中创建一个文件

然后我跑
php app/console swiftmailer:spool:send

并得到这个回应
[2015-12-29 18:54:40] Processing default mailer... 1 emails sent

所以看起来它已经工作了,但没有发送任何内容并且/var/log/mail.log 没有显示任何新电子邮件。

当我将配置设置为内存假脱机时,电子邮件工作没有任何问题,我更改的只是 config.yml
swiftmailer:
    spool: { type: memory }

变成
swiftmailer:
    spool:
        type: file
        path: '%kernel.root_dir%/spool'

我正在使用 sendgrid 和 postfix 来实际发送电子邮件,但我不确定这些电子邮件是否会到达 postfix,因此这可能没有任何区别。

最佳答案

问题最终成为默认环境。我需要做的就是指定一个除 dev 之外的环境

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

关于Symfony 2 和 Swiftmailer 不支持文件假脱机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34517413/

相关文章:

symfony - 如何在 SonataAdminBundle 中使用角色

php - 在 Symfony2 和 Twig 中为文件添加资源路径前缀

php - 如何在 yii2 中使用 Swift_Plugins_AntiFloodPlugin

doctrine - Symfony 2.7/3 - Doctrine : You have requested a non-existent service "fos_user.doctrine_registry"

php - Symfony2 Can't inherit abstract function Validator\ValidatorInterface::validate() (之前在\Validator\ValidatorInterface中声明了抽象)

forms - 轻松管理 : custom type for a field

PHP SOAP 过程 'functionName' 不存在

php - '无法与主机 smtp.gmail.com 建立连接 [无法找到套接字传输 "ssl"

php - Laravel 5.5 - 邮件无法使用 `mail` 驱动程序

symfony - 使用 Symfony 2.7 进行 JWT 身份验证