I've upgraded my laravel instance from version 5.6 to version 5.7. Now I try to use the built-in email verification from laravel.
My problem is that I don't get an email after successful registration when I use the "resend" function the email arrives.
What is the problem?
I had this exactly same problem. That is default code from Laravel.
In order to send the email after successful registration you can do this workaround:
at App\Http\Controllers\Auth\RegisterController
change this:
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
to this:
protected function create(array $data)
{
$user = User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
$user->sendEmailVerificationNotification();
return $user;
}
I also have had the same issue. As I checked the source code, it isn't necessary to implement to call the sendEmailVerificationNotfication()
method, you just should add the event handler to your EventServiceProvider.php
, as because of your event handler was previously created, so Larael can't update that. It should look like this:
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,
],
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With