Monday, February 27, 2017

[SOLVED]Laravel 5.2 Auth Scaffolding Reset Password Email Not Firing - Is it queued?

Ok so I am currently using Mandrill for email. I have assumed this is not the issue. This test route, for example fires fine.
 public function email($emailAddress){
        $data = array(
            'email'     => $emailAddress,
            'name'      => 'Test Name'
            );
        $result = Mail::queue('emails.test', $data, function ($message) use ($data){
            $message->from(Config::get('settings.contact_form_from.address'), Config::get('settings.contact_form_from.name'));
            $message->sender(Config::get('settings.contact_form_from.address'), Config::get('settings.contact_form_from.name'));
            $message->to($data['email'], $data['name']);
            $message->subject('Test email to: ' . $data['email']);
        });
        return $this->response($result);
    }

This is using the queue function. If adjusted to Mail::send() also work's fine. Thus all my queue handlers and mail env variables are working fine. (I can see both these emails in Mandrill).
So my issue is the the password reset functionality which I have installed using the Laravel 5.2 Auth Scaffolding.
So, the route etc all works fine - just no email sends.
It correctly identifies if the user does/doesn't exist (displays the correct error message).
So then I have a look through source code and got slightly lost, help is needed!
If i look in here... ...Illuminate\Foundation\Auth\ResetPasswords.php I can see this method.
public function sendResetLinkEmail(Request $request) { $this->validateSendResetLinkEmail($request);
$broker = $this->getBroker();

$response = Password::broker($broker)->sendResetLink(
    $this->getSendResetLinkEmailCredentials($request),
    $this->resetEmailBuilder()
);
switch ($response) {
    case Password::RESET_LINK_SENT:
        return $this->getSendResetLinkEmailSuccessResponse($response);
    case Password::INVALID_USER:
    default:
        return $this->getSendResetLinkEmailFailureResponse($response);
}

}
If I break at $response I am getting response that it is sent correctly. So I assume it is something to do with Password::broker section, the code here completely looses me.
Any help much appreciated!



via Matt The Ninja

Advertisement