When I try to send mails via Laravel Mail class, I get the following error:
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
I have created a mail class using php artisan make:mail Contact, created the blade view 'contact' in the directory mails and created a controller, called in web.php route file.
The Contact class looks like this:
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');
}
}
This is my email configuration - used 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"
]
]
]
In the Controller file I call the Mail class this way:
\Mail::to('mail@example.com')->send( new Contact );
I already checked those questions:
Too few arguments to function Db::__construct(), 0 passed in
Laravel: Too few arguments to function Illuminate\Support\Manager::createDriver()
I already executed:
- php artisan config:clear
- php artisan vendor:publish
I'm confused, I did the same a explained in this tutorial video: https://laracasts.com/series/laravel-from-scratch-2017/episodes/26