我创建了一个每天自动发送电子邮件的命令。
我正在创建这样的命令:
<?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!');
}
}
然后在内核中注册它:
<?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();
}
}
我列出了所有工匠命令,我可以看到我的新命令电子邮件:发送 - 因此它已创建,但当我尝试运行它时(php artisan emails:send)
我得到了这个:
[Swift_TransportException]
Process could not be started [The system cannot find the path specified.
]
有什么问题?