Skip to content


Subversion checkout URL

You can clone with
Download ZIP


[RFC] Possibility to define several mailers #6

jalliot opened this Issue · 11 comments

8 participants


The use case would be if some mails are kinda urgent/high priority (and then would be sent either directly or by the memory spool) but others have a low priority and should not affect the users' experience (and thus rather be sent by a cron job flushing a file spool).

I imagine it would allow other use cases including plugins specific things...

What do you think? What I'm thinking about is the kind of thing DoctrineBundle does with its configuration (allowing to define several connections/managers but also a default one with simpler config).


The way DoctrineBundle does it is by making the DI extension ultra complex. I don't think it is worth going this way for SwiftmailerBundle. The object graph is not so complex for SwiftMailer so it should not be too painful to define a second service if you need it.


For what it's worth, I'd be interested in this feature. I think it's a pretty common scenario that some messages are high priority and should be sent like $this->getPriorityMailer()->send(). But @stof is right that's it's easy enough to just define the service yourself.


I don't know if this is the right place to ask but how do you define that second mailer service?


@barretodavid In YAML something like:

        class: Swift_Mailer
            - "@some_transport"

You basically just define a service as you would normally do, except configure it such that it will send the email right away. To get the service, do something like: $container->get('priority_mailer').

You can also look in the Swiftmailer bundle to see how it's defined, and just replicate it yourself as necessary.


When using the second mailer service there seems to be no way to set delivery_address(for dev environment).


On Llyr's comment: I think it's a major problem that you can't define multiple mailers without creating your own service.

The problem here is that SwiftMailerBundle exposes some configuration options (delivery_address) That can't be replicated with your own service (at least no way that I've found).


@jtet it can be. Simply do it the same way than SwiftmailerBundle. All it does with the config is defining some services. SwiftmailerBundle has exactly the same possibilities than you when defining services


Hi guys,

@jtet @kbond, @jonathaningram @jalliot @Llyr @lstrojny please take a look at #34

And this PR too: symfony/symfony#8005


+1 for this feature as this is not as easy as it may look at first to define an additionnal mailer

I had to implement a classic memory spool mailer and another file spool mailer together, a lot of things had to be redefined


Thx @tkleinhakisa ;)

By now we're waiting for @fabpot advice on some eventual code move between the bridge & the bundle so please +1 the following PR if you want to accelerate the process. The more popular the PR is, the fastest it should be merged ;)


Closing for #34

@jalliot jalliot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.