Daniel Centore Daniel Centore - 1 year ago 113
PHP Question

How do I manually send a password reset request in Laravel 5.2?

I would like to manually send a password reset request to a specific user (not the one currently logged in) from within a controller. I did some digging around in the Laravel code and it seems like I should be calling

postEmail(Request $request)
, but I can't seem to figure out how to get access to the right
instance to call it.

Answer Source

Why not just something like this for your controller:


namespace Illuminate\Foundation\Auth;

use Illuminate\Http\Request;
use Illuminate\Mail\Message;
use Illuminate\Support\Facades\Password;

class YourController extends Controller
    public function sendEmail()
        $credentials = ['email' => $email_address];
        $response = Password::sendResetLink($credentials, function (Message $message) {

        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)]);

You don't really explain the context of how you want to send this, so adjust accordingly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download