Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sonu's avatar
Level 3

Laravel 5.1 Resest Password

Hey guys i am facing iccuse at reset password in Laravel 5.1 My code works but i did'nt get any email . And also Mandrill don't show any email sent. But i receive email on user registration. Here is my code

public function getEmail(Request $request)
    {
        return view('Frontend.auth.password');
    }
    
    public function postEmail(Request $request)
    {
        $this->validate($request, ['email' => 'required|email']);
        $response = $this->passwords->sendResetLink($request->only('email'), function($m)
        {
            $m->subject($this->getEmailSubject());
        });

        switch ($response)
        {
            case PasswordBroker::RESET_LINK_SENT:
                $message = "Password recovery link has been send to your email address";
                Toastr::success($message, $title = null, $options = []);
                return redirect()->back();
            case PasswordBroker::INVALID_USER:
                return redirect()->back()->withErrors(['email' => trans($response)]);
        }
    }

    protected function getEmailSubject()
    {
        return isset($this->subject) ? $this->subject : 'Your Password Reset Link';
    }
    
    public function getReset($token = null, Request $request)
    {
        if (is_null($token))
        {
            throw new NotFoundHttpException;
        }
            $messages = "Create your new password";
            Toastr::info($messages, $title = null, $options = []);
            return view('Frontend.auth.reset')->with('token', $token);
    }

In Success case i recived the Message Password recovery link has been send to your email address

THis code works in Laravel 5 like a charm. but not sending email with 5.1 whats should i have to do. ?

0 likes
5 replies
bashy's avatar

Have you tested with Mailtrap.io? Have you tried with 'pretend' => true, in mail.php settings?

Sonu's avatar
Level 3

@bashy Yes its true 'pretend' => true,. i am receving emails on user registration . but don't on password reset. My this code works perfect in Laravel 5

thomaskim's avatar

@Sonu When you put $this->passwords->sendResetLink, what is $this->passwords referring to? Are you creating it in the constructor? If not, you might want to change that to PasswordBroker::sendResetLink.

DerekPollard's avatar

Hi Sonu! I ran into this problem as well, what I had to do was update the settings in my .ENV:

MAIL_DRIVER=smtp
MAIL_HOST=a2ss15.somehost.com
MAIL_PORT=2525
MAIL_USERNAME=some@email.com
MAIL_PASSWORD=mypassword

The above must reflect the mail settings of your server/host.

akshaygohil's avatar

I had the same problem, fixed it doing the following.

Change your mail.php from,

'from' => array('address' => null, 'name' => null),

to something like

'from' => array('address' => 'donotreply@domain.com', 'name' => "Do Not Reply"),
1 like

Please or to participate in this conversation.