我正在使用smtp协议使用mailtrap发送邮件。它在localhost中工作得很好,但它给出了错误。
Symfony \ Component \ Debug \ Exception \ FatalThrowableError类型错误:太多 函数Illuminate \ Support \ Manager :: createDriver()的几个参数, 0传入 的public_html /供应商/ laravel /框架/ SRC /照亮/支持/ Manager.php 第88行和预期的1
.env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=name
MAIL_PASSWORD=pass
MAIL_ENCRYPTION=null
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
答案 0 :(得分:0)
首先:确保您在配置文件夹集
中有mail.php和services.php分别如下:
mail.php
<?php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailtrap.org'),
'port' => env('MAIL_PORT', 2525,
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
和services.php(请注意,这包括mailgun配置)
<?php
return [
'mailgun' => [
'domain' => env('MAILGUN_DOMAIN'),
'secret' => env('MAILGUN_SECRET'),
],
'ses' => [
'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'),
'region' => 'us-east-1',
],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
],
];
在你的boostrap / app / php文件上添加
$app->configure('mail'); // this is to configure the mail
$app->configure('services'); // and to configure the services
//$con = env('MAIL_DRIVER');
// dd($con);
dd(config('mail')); // this is to print the mail configuration so you can know what mail configuration are being read.
return $app;
在终端内运行php artisan serve
只是为了查看邮件配置的内容。
请注意 我注意到简单的修复只是使用凭据更新/修改.env文件(使用gmail smtp服务器作为示例)
MAIL_DRIVER_=smtp (instead of MAIL_DRIVER, update it the mail.php)
MAIL_HOST_=smtp.gmail.com (instead of MAIL_HOST)
MAIL_PORT_=587
MAIL_USERNAME=youremail@domain.com
MAIL_PASSWORD=yourpassword
MAIL_ENCRYPTION=tls
MAILGUN_DOMAIN=
MAILGUN_SECRET=
之后,如果您已经在运行服务器。杀死它并重新运行它。这应该可以解决你的错误,
<强>原因强>
由于我无法解释的原因,在我应用上述更改之前,某些邮件配置参数并未反映出来。
其次我后来将.env设置更改为原始名称,消除了额外的&#34; _&#34;以及更新了mail.php,并且必须杀死已经运行的服务器并在它反映并运行良好或工作之前重新运行它。
希望这有帮助