Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add mailer name to data for SentMessage and MessageSending events #46079

Merged
merged 2 commits into from
Feb 11, 2023
Merged

Conversation

colq2
Copy link
Contributor

@colq2 colq2 commented Feb 10, 2023

This PR adds the mailer name to data for the MessageSending and SentMessage events.

It is impossible to detect through which mailer a mailable is sent when listening to the MessageSending and SentMessage event.

There are some use cases where this is a benefit:

  1. Stop sending the email depending on the mailer.

  2. Storin outgoing mail with its mailer (from a package)

When using different mailers and a custom failover logic, it is important to know from which mailer a message was sent. Especially when using a package and the only way to intercept mails are the events.

Accessing the mailer from event data looks like this:

Event::listen(MessageSending::class, function(MessageSending $event){
    $mailer = $event->data['mailer'];
});

@taylorotwell taylorotwell merged commit dd3abef into laravel:9.x Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants