maxxxir's avatar

reset password not sending email

i have followed official document for password reset

https://laravel.com/docs/9.x/passwords

i've created a controller with 2 methods like document says

everything seem to work , i see new password reset stored in database but i'm not receiving any email containing reset link

i've manually dispatched an email job on the forgot method of my controller to see if my email credentials are ok and i did receive the email so they are correct

this part of documentation is vague , there is no mention how email will be sent ... i assume it will send the email automatically washout any need to create and email/notification/job ... by me ? am i missing anything here ?

here is my code

function forgot(Request $request){
    $request->validate(['email' => 'required|email']);

    $status = Password::sendResetLink(
        $request->only('email')
    );

    SendEmailJob::dispatch('my name', '[email protected]', 'dummyToken');


    return $status === Password::RESET_LINK_SENT
        ? response(['message' => __('messages.EmailSent')])
        : response(['message' => __($status)], 400);
}

i've added

    SendEmailJob::dispatch('my name', '[email protected]', 'dummyToken');

to see if my mail works ... i assume i dont need to send an email and i should receive the email without this

0 likes
5 replies
automica's avatar

If you are using a job then you need to start your queue to send it,

1 like
maxxxir's avatar

@automica thanx but like i've said when i dispatch an email job

SendEmailJob::dispatch('my name', '[email protected]', 'dummyToken');

in my method i did receive the email so it's working and my email credentials are correct

also my QUEUE_CONNECTION is set to sync so i dont need to start queue

1 like
Snapey's avatar

Did you read

You may be wondering how Laravel knows how to retrieve the user record from your application's database when calling the Password facade's sendResetLink method. The Laravel password broker utilizes your authentication system's "user providers" to retrieve database records. The user provider used by the password broker is configured within the passwords configuration array of your config/auth.php configuration file. To learn more about writing custom user providers, consult the authentication documentation.

So the password broker first has to find the right user model using the email address you pass, and then uses a notification to send the email

1 like
maxxxir's avatar

@Snapey thanx are you suggesting im using a wrong email and laravel cant find the user ?

like i've said i can see password reset and generated token stored in database , so it has found the user ... also you get validation error if it cant find the user in the first place

so it has found the user .... it's just not sending email is there an extra step for processing notifications or something else im missing ?

1 like
Snapey's avatar

@maxxxir try what you did before to test sending the email, but this time use a notification.

2 likes

Please or to participate in this conversation.