<?php
declare(strict_types=1);

namespace FreshCloud\Mail\SmtpClient;

final readonly class SmtpMessage
{
    public function __construct(
        public string $from,
        public string $subject,
        public string $body,
        public array $to = [],
        public array $cc = [],
        public array $bcc = [],
        public ?string $htmlBody = null,
        public array $attachments = [],
    ) {
        if (empty($to) && empty($cc) && empty($bcc)) {
            throw new \InvalidArgumentException('At least one recipient must be provided');
        }

        if (!filter_var($from, FILTER_VALIDATE_EMAIL)) {
            throw new \InvalidArgumentException('From address is invalid');
        }

        if (empty($subject)) {
            throw new \InvalidArgumentException('Subject cannot be empty');
        }
    }
}