<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;

class TestEmail extends Command
{
    protected $signature = 'test:email {to : Recipient email address}';
    protected $description = 'Send a test email using the existing view';

    public function handle(): int
    {
        $to = $this->argument('to');

        Mail::send('mails.test', [], function ($message) use ($to) {
            $message->to(explode(',', $to))->subject('Test Email');
        });

        $this->info('Test email sent.');

        return self::SUCCESS;
    }
}
