我有live
个laravel应用程序,并且正在开发password reset
功能。
具有以下routes
Route::get('passwords/reset/{token?}','Auth\ResetPasswordController@showResetForm');
Route::post('passwords/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
Route::post('passwords/reset', 'Auth\ResetPasswordController@reset')->name('password.reset');
单击Forgot My Password
链接会将我定向到以下form
<form action="{{ url('passwords/email') }}" method = 'post'>
<input type="email" name = 'email' class="form-control" id="exampleInputPassword1" placeholder="Enter Your Email Here" style = 'text-align:center'>
<button type='submit'>Send Link to Email to Reset Password</button>
</form>
从这个form
我希望用户放置他/她的email
,我们拍摄一个token
到email Id
的重置链接。
为此,我有ForgotPasswordController
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
// We will send the password reset link to this user. Once we have attempted
// to send the link, we will examine the response then see the message we
// need to show to the user. Finally, we'll send out a proper response.
$response = $this->broker()->sendResetLink(
$request->only('email')
);
if ($response === Password::RESET_LINK_SENT) {
return back()->with('status', trans($response));
}
// If an error was returned by the password broker, we will get this message
// translated so we can notify a user of the problem. We'll redirect back
// to where the users came from so they can attempt this process again.
return back()->withErrors(
['email' => trans($response)]
);
}
我想与Email
发送email Id
到那个token
,但是没有发送。
以下是我的.env
文件
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=25
MAIL_USERNAME=myEmail@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
在我的config/mail.php
中,我有这个
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'myEmail@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'myName'),
],
注意
我已为我的less secure apps
帐户允许gmail
,但仍然没有收到电子邮件,并且正在对实时站点进行这些更改。
这就是storage/logs
显示的
local.ERROR:SQLSTATE [42S02]:找不到基表或视图:1146表'alle_voertuigen_nl_carseller.password_resets'不存在(SQL:从
password_resets
删除,其中
尽管我有手动创建的password_resets
表,而不是通过php artisan migrate
创建的表,因为我正在更改实时站点,并且我不知道如何使用command line
用于已部署的项目
请帮助我
谢谢
答案 0 :(得分:0)
如果使用tls,则应使用587端口,而不是25
答案 1 :(得分:0)
使用以下详细信息更改您的.env文件
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxxx@gmail.com
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=tls
请勿使用您的原始密码。在您的Google帐户中创建一个应用密码。
将更改保存到.env文件后,运行php artisan config:cache
命令。
答案 2 :(得分:0)
只需修改一下您的mail.php文件,就像下面我静态提到的那样,还有一件事,请从.env文件中删除邮件参数。 不要忘记运行“ php aritsan cache:clear”和“ php artisan config:cache”命令。 这也将帮助您使用本地服务器和实时服务器。
返回[
/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
| "sparkpost", "log", "array"
|
*/
'driver' => 'smtp',
/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/
'host' => 'smtp.gmail.com',
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/
'port' => 587,
/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/
'from' => [
'address' => 'Your gmail address',
'name' => 'Your Name',
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/
'encryption' => 'tls',
/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/
'username' => 'Your gmail address',
'password' => 'Your Gmail password',
/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/
'sendmail' => '/usr/sbin/sendmail -bs',
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
],
];