So I am trying to send password reset email and this is my routes for it:
Route::get('/password/remind', function () {
return view('auth.password-remind');
})->name('password.remind');
Route::post('/password/remind', [RemindController::class, 'store'])->name('password.send');
Route::get('/password/reset/{token}', function () {
return view('auth.password-reset');
})->name('password.reset');
And inside RemindController
I have:
$data = $this->validate($request, [
'email' => ['required', 'exists:users,email'],
'_token' => '',
]);
Mail::send('emails.password-reset', [
'token' => $data['_token']
], function ($message) use ($data) {
$message->subject('Reset Password Request');
$message->to($data['email']);
});
And then this is the email it should send:
Reset password <a href="{{ route('password.reset', $token) }}">here</a>
This is my form for sending email:
<form action="{{ route('password.send') }}" method="post" class="remind-form">
<input name="_token" type="hidden" value="{{ csrf_token() }}"/>
<div class="form-group" error="email">
<input class="form-control" name="email" type="email" />
</div>
<div class="form-footer">
<button type="submit" class="auth-btn">Send</button>
</div>
</form>
But when I submit I get errors:
Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.
my .env
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=465
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=myemail@gmail.com