J
J
jazzus2019-02-16 03:52:41
Laravel
jazzus, 2019-02-16 03:52:41

Why is an auto-email verification email not sent?

When registering a user (Laravel Auth), a verification email should be sent. And this letter stopped sending by itself. Only if you click on the request link of this letter (such as if you did not receive a letter, click here). In this case, the letter arrives immediately. And if the user has registered and does not click anywhere, then no.
There are no
errors in the logs.
The user sees a page with a message that the email needs to be verified.
The user has no access except to this page (i.e. the rule itself works)
The last event with registration is included in web.php - I made an entry in EventServiceProvider.php
Auth::routes(['verify' => true]);

'Illuminate\Auth\Events\Registered' => [
            'App\Listeners\Auth\LogRegisteredUser',
        ],

In the event - a log entry about a new registration.
What to see/check? I included a log in env:
MAIL_DRIVER=log
But only the message that is sent using Mail in the RegisterController (notification to the moderator) got there. I thought maybe sending to the user conflicts with sending to the moderator, commented out, there is no result. As a result, all events related to mail work, except for auto-mail verification

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jazzus, 2019-02-16
@jazzus

The error was, just in EventServiceProvider.php.
There were conflicting classes (the one that is commented out)

Registered::class => [
            SendEmailVerificationNotification::class,
            'App\Listeners\Auth\LogRegisteredUser'
        ],

        // 'Illuminate\Auth\Events\Registered' => [
        //     'App\Listeners\Auth\LogRegisteredUser',
        // ],

It's not clear why Laravel didn't throw an error. Just didn't send a letter.
Also, if anyone has the same problem, don't forget
php artisan config:cache

R
Roman, 2019-02-16
@procode

Look in the spam folder
Test the mail from the console:
echo "Test of Mail body" | mail -s "subject" [email protected] Replace
[email protected] with your real address

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question