Verify email in Laravel 9

71 Views Asked by At

I want to do email verification. Actually, it succeeded, but only to the email in the .env file. Why didn't other users receive the email verification link?

Model

class User extends Authenticatable implements MustVerifyEmail

web

Auth::routes(['verify' => true]);

controller

$this-\>middleware(\['auth', 'verified'\]);

.env

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=zdmqlfstftkdvrsz
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="Travel"

Why was it only sent to mymail but not to other emails?

3

There are 3 best solutions below

0
Ivar On

You could try to make MAIL_FROM_ADDRESS equal to MAIL_USERNAME. If that does not match it can be disallowed

0
Karl Hill On

If you want to debug this further, you can temporarily modify the sendEmailVerificationNotification() method in your User model to log some info.

public function sendEmailVerificationNotification()
{
    $email = $this->getEmailForVerification();

    // Log the email address to which the verification link would be sent
    Log::info('Sending email verification link to: ' . $email);

    $this->notify(new Notifications\VerifyEmail);
}
0
Lyndon On

MAIL_FROM_ADDRESS needs to be an actual email address that exists. I realized that made-up email addresses like "[email protected]" don't work.