lundi 4 septembre 2017

laravel - update the from email address dynamically on password reset link

When a user resets their password laravel will send the email from the from address value in config/mail.php

'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
    'name' => env('MAIL_FROM_NAME', 'Example'),
],

My problem is that I want this email to be sent from a different email address depending on which domain is used to access my server.

So if a user entered my server through website1.com I want the from address to be email@website1.com and from website2.com to be email@website2.com

It would not make sense for me to change or hard code a from email address into either my config/mail.php or .env so how can I do this?

I have App\Website.php model, which contains an 'email_address' field. I need this to be applied when the password reset email occurs.

For all my other emails it is fine because I send the emails myself, however, the passwords reset email is sent through laravel itself.

Any ideas?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire