G
G
Gleb Starkov2020-11-26 15:03:25
Laravel
Gleb Starkov, 2020-11-26 15:03:25

How to set up email verification in Laravel to send from another email?

Hello!
I set up email verification according to the documentation in Laravel 8, everything works fine.
But, it is required to send not from the main box, but from an additional one.
I set up an additional mailbox in mail.php and in .env
Is there a way to make it send from an additional mailbox during verification?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gleb Starkov, 2020-11-26
@colonel

In general, I decided myself.
In App\Models\User overridden method:

public function sendEmailVerificationNotification()
    {
        $this->notify(new VerificationEmail());
    }

And created the VerificationEmail class inherited from Illuminate\Auth\Notifications\VerifyEmail
In it, overridden the method:
protected function buildMailMessage($url)
    {
        return (new MailMessage)
            ->mailer('activate')
            ->from('[email protected]', config('app.name'))
            ->subject(Lang::get('Verify Email Address'))
            ->line(Lang::get('Please click the button below to verify your email address.'))
            ->action(Lang::get('Verify Email Address'), $url)
            ->line(Lang::get('If you did not create an account, no further action is required.'));
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question