我创建了一个自定义的SwiftMailer插件,我希望在我的Symfony 2.3应用程序中默认使用SwiftMailer。在这方面,我可以找到的唯一文档是:http://symfony.com/doc/current/reference/dic_tags.html#swiftmailer-plugin

我已将服务设置如下:

acme_test_bundle.swiftmailer.embed_images:
    class: Acme\TestBundle\SwiftMailer\Plugins\ImageEmbedPlugin
    tags:
        - { name: swiftmailer.plugin }

即使已创建此服务,SwiftMailer也不会使用该插件。我做错了什么,还有什么我应该做的?

最佳答案

我自己弄清楚了这一点。

与Symfony 2.3文档所说的相反,您需要标记将使用的邮件服务(通常是“默认”邮件)。

因此,我需要将 swiftmailer.plugin 更改为 swiftmailer.default.plugin

因此,服务定义现在为:

acme_test_bundle.swiftmailer.embed_images:
    class: Acme\TestBundle\SwiftMailer\Plugins\ImageEmbedPlugin
    tags:
        - { name: swiftmailer.default.plugin }

关于php - Symfony 2.3 : How do you configure SwiftMailer to automatically use a custom plugin?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19542927/

10-12 16:28