Mail middleware #38176
Unanswered
jameslkingsley
asked this question in
Ideas
Mail middleware
#38176
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there scope to add middleware to the Mail system in Laravel? This would work the same as it does elsewhere in the framework, offering a way to continue or back out of a process.
Reasons why you'd want mail middleware:
Ideally the middleware would be checked before Laravel starts interacting with the Swift mailer, so that the middleware is being called early enough to be useful still. I say this because the Swift mailer can be a tricky beast to tame especially if you want to validate email addresses before Swift does so itself and throws an exception.
How would it be used?
Fluently:
Config:
Mailable:
And then the middleware itself would receive the mailable instance, with the ability to see the recipients, view etc.
An alternative change to mail to support this indirectly would be more DI usage throughout the
MailManager
andMailer
classes, as right now you have to adopt hacky approaches to override them.Beta Was this translation helpful? Give feedback.
All reactions