[Mailer] Using multiple transports #46372
Replies: 1 comment
-
Fixed by #59781 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
At my company we want to rely on the Mailer component to handle all our emails.
Because of our business constraints, we need to:
I have set up my Mailer configuration as follows:
I am adding a
X-Transport
text header to my emails containing one of the configure values (assoconnect_transactional
,springly_transactional
, ....)However, all my emails are sent through the first (and default)
assoconect_transactional
transport.I noticed that the
X-Transport
header was not removed from our emails.I have overridden the default
Symfony\Component\Mailer\Messenger\MessageHandler
handler to add some business logic, injecting in it theTransportInterface
as it was done and calling$transport->send(...)
.And here is the problem. When I dump the class of the
TransportInterface
I get, I haveMailgunHttpTransport
directly.If I understand the multiple transport logic, I should pass at one moment inside
Symfony\Component\Mailer\Transport\Transports
class where the logic is done to choose the transport based on theX-Transport
header.However, if I try to inject the
Transports
class as a type hint, I get an error saying I need to use theTransportInterface
.How should I go around this issue to be able to manage both asynchronous & multiple transports sending?
Cheers
Update: The problem resides only in using multiple transports.
But I still don"t get why, as I seem to be following the documentation usecase :/
Beta Was this translation helpful? Give feedback.
All reactions