phplaravelforgot-password

I have success message but no email received in my forgot password laravel 5.6


This my success message but no email received in my email box

enter image description here

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxxxx@gmail.com
MAIL_PASSWORD=xxxxxx
MAIL_ENCRYPTION=tls

i use mail_client instead of email so i override some function , also i add in my client model this->mail_client

class ForgotPasswordController extends Controller{
use SendsPasswordResetEmails;

public function sendResetLinkEmail(Request $request)
{
    $this->validateEmail($request);

    $response = $this->broker()->sendResetLink(
        $request->only('mail_client')
    );

    return $response == Password::RESET_LINK_SENT
        ? $this->sendResetLinkResponse($response)
        : $this->sendResetLinkFailedResponse($request, $response);
}
protected function validateEmail(Request $request)
{$this->validate($request, ['mail_client' => 'required|email']);
}


protected function sendResetLinkFailedResponse(Request $request, $response)
{
    return back()->withErrors(
        ['mail_client' => trans($response)]
    );
}

public function __construct()
{
    $this->middleware('guest');
}}

Solution

  • Finally i find the answer : first i need override that method (getEmailForPasswordReset and routeNotificationFor) into model Client:

    public function getEmailForPasswordReset()
    {
        return $this->mail_client;
    }
    
    public function routeNotificationFor($driver)
    {
        if (method_exists($this, $method = 'routeNotificationFor'.Str::studly($driver))) {
            return $this->{$method}();
        }
    
        switch ($driver) {
            case 'database':
                return $this->notifications();
            case 'mail':
                return $this->mail_client;
            case 'nexmo':
                return $this->phone_number;
        }
    }
    

    and implement:

     use Illuminate\Support\Str
    

    into ForgotPasswordController need override the method called sendResetLinkEmail ,validateEmail and sendResetLinkFailedResponse:

    public function sendResetLinkEmail(Request $request)
        {
            $this->validateEmail($request);
    
            // We will send the password reset link to this user. Once we have attempted
            // to send the link, we will examine the response then see the message we
            // need to show to the user. Finally, we'll send out a proper response.
            $response = $this->broker()->sendResetLink(
                $request->only('mail_client')
            );
    
            return $response == Password::RESET_LINK_SENT
                        ? $this->sendResetLinkResponse($response)
                        : $this->sendResetLinkFailedResponse($request, $response);
        }
    
        protected function validateEmail(Request $request)
        {
            $this->validate($request, ['mail_client' => 'required|email']);
        }
    
        protected function sendResetLinkFailedResponse(Request $request, $response)
        {
            return back()->withErrors(
                ['mail_client' => trans($response)]
            );
        }
    

    And dont forget to chage name input in your blade . That's all .