HEX
Server: LiteSpeed
System: Linux d8 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: wbwebdes (3015)
PHP: 8.1.31
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/wbwebdes/domains/uren-registratie.blankevoort.net/public_html/src/Command/MailTestCommand.php
<?php

/*
 * This file is part of the Kimai time-tracking app.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\Command;

use App\Event\EmailEvent;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Mime\Email;

#[AsCommand(name: 'kimai:mail:test', description: 'Send a test email')]
final class MailTestCommand extends Command
{
    public function __construct(private readonly EventDispatcherInterface $dispatcher)
    {
        parent::__construct();
    }

    protected function configure(): void
    {
        $this->addArgument('to', InputArgument::REQUIRED, 'The email address to send the email to');
        $this->addOption('from', null, InputOption::VALUE_OPTIONAL, 'The sender of the message', '[email protected]');
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $message = new Email();
        $message->to((string) $input->getArgument('to')); // @phpstan-ignore-line
        $message->from((string) $input->getOption('from')); // @phpstan-ignore-line
        $message->subject('Kimai test email');
        $message->text('This is an email for testing the text body.');

        $this->dispatcher->dispatch(new EmailEvent($message));

        return Command::SUCCESS;
    }
}