我根据mail docs配置了laravel 5.1。发送邮件工作正常。
下一步是根据resetting passwords文档添加重置密码。在这里,我很难将链接发送到reset-password公式。
似乎没有触发发送重置邮件的功能。我还使用config/mail.php
配置pretend = true;
进行了检查。日志文件中没有条目,发送了一封电子邮件。
不知怎的,它也很难调试,因为我找不到触发重置电子邮件的功能。
这是我的配置:
# ...
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mail.org
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAILGUN_DOMAIN=mg.foo.com
MAILGUN_SECRET=key-foobar.etc
# ....
//...
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
//...
// ...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' => 'foo@test.com', 'name' => 'foo'],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'pretend' => false,
// ...
// ...
Route::group([
'prefix' => LaravelLocalization::setLocale(),
'middleware' => [ 'localeSessionRedirect', 'localizationRedirect' ]
], function() {
//Route::controllers([ 'password' => 'Auth\PasswordController', ]);
// works only if the user is logged out!!!1
// Password reset link request routes...
Route::get('password/email', 'Auth\PasswordController@getEmail');
Route::post('password/email', 'Auth\PasswordController@postEmail');
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\PasswordController@getReset');
Route::post('password/reset', 'Auth\PasswordController@postReset');
});
//...
@extends('layout')
@section('content')
<div class="container">
<form method="POST" action="/password/email">
{!! csrf_field() !!}
@if (count($errors) > 0)
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
@endif
<div class="row">
<div class="col-md-6">
{!! Form::label('email', trans( 'mes.email' )) !!}
<input type="email" name="email" value="{{ old('email') }}" class="form-control">
</div>
<div class="col-md-8">
<button type="submit" class="btn">
Send Password Reset Link
</button>
</div>
<div>
</form>
</div>
@endsection
答案 0 :(得分:1)
问题是路线不正确。文档中的示例对action
元素中的form
值进行了硬编码。
这并不反映我的路线配置。通过以下更改,密码重置电子邮件可以正常运行:
// change route to a named route
// Route::post('password/email', 'Auth\PasswordController@postEmail');
Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\PasswordController@postEmail']);
<!-- Use the named route in the form builder and remove csrf_field -->
{!! Form::open(['route' => 'password.email']) !!}