I'm creating a command for sending an email automatically daily.
I'm creating the command like this:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class SendEmail extends Command
{
protected $signature = 'emails:send';
protected $description = 'Sending emails to the users.';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$data = array(
'name' => "МГ 'Константин Величков', гр. Пазарджик",
);
Mail::send('emails.test', $data, function ($message) {
$message->from('mg.kvelichkov@gmail.com', 'МГ "Константин Величков"');
$message->to('yoannam1502@gmail.com')->subject('Оценки');
});
$this->info('The emails are send successfully!');
}
}
And then register it in Kernel like this:
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
protected $commands = [
Commands\Inspire::class,
Commands\SendEmail::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('emails:send')->daily();
}
}
I'm listing all artisan commands and i can see my new comand emails:send - therefore its created, but when i try to run it (php artisan emails:send)
i got this:
[Swift_TransportException] Process could not be started [The system cannot find the path specified. ]
What is the problem?
$transport = Swift_MailTransport::newInstance();