Php 未从服务器发送电子邮件

Php 未从服务器发送电子邮件,php,laravel,Php,Laravel,我有livelaravel应用程序,我正在开发密码重置功能 具有以下路线 Route::get('passwords/reset/{token?}','Auth\ResetPasswordController@showResetForm'); Route::post('passwords/email', 'Auth\ForgotPasswordController@sendResetLinkEmail'); Route::post('passwords/reset', 'Auth\Reset

我有
live
laravel应用程序,我正在开发
密码重置
功能

具有以下
路线

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');
点击
忘记密码
链接可将我指向以下
表单

<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>
}

我想用
标记
向该
电子邮件Id
发送
电子邮件,但这不是发送

下面是我的
.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'),
],
注意

我允许我的
gmail
帐户使用
不太安全的应用程序
,但我仍然没有收到电子邮件,我正在对一个实时站点进行这些更改

这就是
存储/日志
显示的内容

local.ERROR:SQLSTATE[42S02]:找不到基表或视图:1146表“alle_voertuigen_nl_carseller.password_resets”不存在(SQL:delete from
password_resets
where
email
=myEmail@gmail.com){“异常”:“[对象](照亮\数据库\查询异常(代码:42S02):

虽然我有
password\u重置了我手动创建的
表,而不是通过
php artisan migrate
,因为我正在对live site进行更改,而且我不知道如何使用
命令行来部署项目

请帮帮我


谢谢

如果您使用tls,您应该使用587端口,而不是25

使用以下详细信息更改.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
命令。

只需修改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,
    ],
],

]

看起来还可以,但我需要看你的php邮件日志。我想它包含一些关于它本身的信息。我需要看你的php邮件日志,你这是什么意思?@LanceHuntertry通过这样的方式捕捉错误:尝试{mail::send('emails.configuration_test',array(),function($email)use($request){$email->to($request->test\u address)->subject('Configuration Test');});}catch(\Exception$e){//这里是错误}你可以添加任何测试控制器,只是为了测试你的邮件系统。但在你这么做之前,请再尝试一件事。清除缓存by:php artisan config:cache然后尝试像以前那样发送电子邮件好的,一方面不是说我正在对实时文件进行这些更改,我如何运行这些命令,如清除缓存,请告诉我因为我在@LanceHunter上搜索这个时间太长了打开你的
存储/日志
,按日期查找最新日志,你应该可以看到更多关于你的电子邮件以及失败原因的信息,你可能会在那里找到你的答案。如果你自己无法找到答案,请将电子邮件日志放到你的问题中,我为什么需要这个
App密码
您能解释一下吗?@jitesh joseTo要通过不直接输入密码来为您的谷歌帐户增加安全性,请使用app Password。
/*
|--------------------------------------------------------------------------
| 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,
    ],
],