1 year ago

How to use event "Illuminate\Mail\Events\MessageSending" to replace $to according to environment

Posted 1 year ago by founders


I am trying to use "Illuminate\Mail\Events\MessageSending" event to replace who the email is sent to depending on the server environment. I have a couple forms, sending emails to a couple of people depending on the subject. I'm trying to figure out a way to tell Mail class this:

If it's production environment, go ahead and send the emails, otherwise, send them only to [email protected]

However, the "MessageSending" event only returns allows me to change $message, not $to.

What should I do?

Please sign in or create an account to participate in this conversation.