Laravel 邮件:函数 Swift_Transport_EsmtpTransport::__construct() 的参数太少

Laravel Mail: Too few arguments to function Swift_Transport_EsmtpTransport::__construct()

当我尝试通过 Laravel 邮件 class 发送邮件时,出现以下错误:

Symfony \ Component \ Debug \ Exception \ FatalThrowableError

(E_RECOVERABLE_ERROR) Type error: Too few arguments to function Swift_Transport_EsmtpTransport::__construct(), 0 passed in /[...]/CustomerCenter/database/factories/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php on line 37 and at least 3 expected

我使用phpartisanmake:mail联系人创建了邮件class,创建了blade查看目录 mails 中的 'contact' 并创建一个控制器,在 web.php 路由文件中调用。

联系人 class 如下所示:

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

class Contact extends Mailable {
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     *
     */
    public function __construct() {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build() {
        return $this->view('emails.contact');
    }
}

这是我的电子邮件配置 - 使用 Config::get('mail')

array:9 [▼
  "driver" => "smtp"
  "host" => "xxx.kasserver.com"
  "port" => "25"
  "from" => array:2 [▼
    "address" => "mail@example.com"
    "name" => "Example"
  ]
  "encryption" => null
  "username" => "xxx"
  "password" => "***"
  "sendmail" => "/usr/sbin/sendmail -bs"
  "markdown" => array:2 [▼
    "theme" => "default"
    "paths" => array:1 [▼
      0 => "/[...]/resources/views/vendor/mail"
]
  ]
]

在控制器文件中,我这样调用邮件 class:

\Mail::to('mail@example.com')->send( new Contact );

我已经检查了那些问题:

我已经执行了:

我很困惑,我在本教程视频中做了同样的解释: https://laracasts.com/series/laravel-from-scratch-2017/episodes/26

好的,出于某种原因,包含路径是: database/factories/vendor/swiftmailer 但它应该是 vendor/swiftmailer.

我没有意识到这一点。我想我的 FTP 同步程序将所有供应商的东西复制到 database/factories。删除东西使 laravel 抛出丢失文件的异常。所以现在我知道该怎么做了:

一个简单的

composer dump-autoload

解决了问题...