symfony / swiftmailer-bundle

Symfony Swiftmailer Bundle
https://symfony.com/swiftmailer-bundle
MIT License
1.56k stars 151 forks source link

Environment variables with custom transports registered as services are not supported #298

Closed alanhartless closed 4 years ago

alanhartless commented 4 years ago

It seems that support for custom transports was removed in https://github.com/symfony/swiftmailer-bundle/pull/159 when using dynamic/environment variables. I was able to circumvent this by using a custom cache pass compiler to override SwiftmailerTransportFactory with a custom one, passed in the service_container as the 4th argument, then return a transport found in the container if it exists otherwise it defaults to the current default behavior.

I assume locking down support to just smtp, sendmail or null was done for a reason but I'm not sure what it is considering the above work around seems to work fine and keeps support for custom transports. Is there a reason I should keep in mind with the hack/work around I implemented?

Just for reference, this is what I had to do https://github.com/mautic/mautic/commit/6f521ab014b14ff7c485232966a5eee7da06ed37

marcinkrawiec commented 4 years ago

@alanhartless I have the same problem. I'm trying to use mailgun transport using symfony/mailgun-mailer, but everything I try fails (the config from the recipie also does not work at all).

Unfortunately I cannot see the commit you linked to. Can you guide me where I can find it? Thanks!

stof commented 4 years ago

@marcinkrawiec symfony/mailgun-mailer is not related to SwiftmailerBundle at all but to symfony/mailer

marcinkrawiec commented 4 years ago

Thank you, @stof . That explains a lot ;)