Laravel 5 Password Reset Email Not Being Sent

16,369

Solution 1

If the issue is invalid sender, make sure you pass the correct sender

$message->from('[email protected]', 'Your Application');

Solution 2

I added those in .env and password reseting is working again

[email protected]
MAIL_FROM_NAME=xxxx
Share:
16,369
Michael
Author by

Michael

Updated on August 02, 2022

Comments

  • Michael
    Michael almost 2 years

    I am trying to implement a password reset on my Laravel 5.1 app. I have followed the docs (http://laravel.com/docs/5.1/authentication#resetting-passwords) to get this working. However whenever I click on my 'reset password' button on my /password/email/ no email is ever sent.

    I have intentionally entered incorrect emails and I am getting the appropriate error however when I enter a correct email no email is sent and I get no type of message or any emails.

    I have looked at my database and it does looks as though a password reset token being created, just no email is sent.

    My email configuration is working properly as other parts of my application sends email properly, only this one section is not sending the emails. Any help will be appreciated as I do not what else to check.

    Michael

    routes.php: `

    // Password reset link request routes...
    Route::get('password/email', ['as' => 'password/email', 'uses' => 'Auth\PasswordController@getEmail']);
    Route::post('password/email', 'Auth\PasswordController@postEmail');
    
        // Password reset routes...
        Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
        Route::post('password/reset', 'Auth\PasswordController@postReset');
    

    password.blade.php:

    <form id="contact-form" class="contact-section" method="POST" action="/password/email">
                <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                <span class="pre-input"><i class="fa fa-envelope-o"></i></span>
                <input class="name plain buffer" type="email" name="email" placeholder="Email" value="{{ old('email') }}">
                <input id="send" class="plain button yellow" type="submit" value="Reset Password">
                  @foreach($errors->all() as $error)
                  <font size="3" color="red">{{ $error }}</font>
                  @endforeach
    
              </form> 
    

    resources/views/emails/password.blade.php:

    Click here to reset your password: {{ url('password/reset/'.$token) }}
    

    Update I have added a Log to the postEmail function.

        public function postEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);
    
        $response = Password::sendResetLink($request->only('email'), function (Message $message) {
            $message->subject($this->getEmailSubject());
     Log::info('Password Reset Execute -1 '); //Does work here
    
    
        });
    
        switch ($response) {
    
            case Password::RESET_LINK_SENT:
                return redirect()->back()->with('status', trans($response));
    
            case Password::INVALID_USER:
                return redirect()->back()->withErrors(['email' => trans($response)]);
        }
    
        Log::info('Password Reset Execute - 2'); //Will not work here
    }