Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

[RFC] Possibility to define several mailers #6

Closed
jalliot opened this issue Apr 20, 2012 · 11 comments
Closed

[RFC] Possibility to define several mailers #6

jalliot opened this issue Apr 20, 2012 · 11 comments

Comments

@jalliot
Copy link

jalliot commented Apr 20, 2012

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).

@stof
Copy link
Member

stof commented Apr 20, 2012

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.

@jonathaningram
Copy link

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.

@barretodavid
Copy link

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

@jonathaningram
Copy link

@barretodavid In YAML something like:

services:
    priority_mailer:
        class: Swift_Mailer
        arguments:
            - "@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.

@Juburin
Copy link

Juburin commented Mar 28, 2013

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

@jtet
Copy link

jtet commented Mar 28, 2013

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).

@stof
Copy link
Member

stof commented Mar 28, 2013

@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

@shouze
Copy link

shouze commented May 13, 2013

Hi guys,

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

And this PR too: symfony/symfony#8005

@tkleinhakisa
Copy link

+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
see https://groups.google.com/forum/?fromgroups#!topic/symfony2/F1IhEQMG1Lo

@shouze
Copy link

shouze commented Jun 12, 2013

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 ;)

@jalliot
Copy link
Author

jalliot commented Jun 18, 2013

Closing for #34

@jalliot jalliot closed this as completed Jun 18, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants