protected function applyArgsToMailService(array $args)
    {
        if (isset($args['body'])) {
            $body = $args['body'];
            if (is_array($body)) {
                $charset = $body['charset'] ?? MailServiceInterface::DEFAULT_CHARSET;
                if (isset($body['content']) && is_string($body['content'])) {
                    $this->mailService->setBody($body['content'], $charset);
                } elseif (isset($body['template']) && is_array($body['template'])) {
                    $name = $body['template']['name'] ?? '';
                    $params = $body['template']['params'] ?? [];
                    if (!empty($name)) {
                        $this->mailService->setTemplate($name, $params, $charset);
                    }
                }
            } else {
                $this->mailService->setBody($body);
            }
        }

        if (isset($args['subject'])) {
            $this->mailService->setSubject($args['subject']);
        }

        if (isset($args['to'])) {
            $this->mailService->getMessage()->setTo($args['to']);
        }

        if (isset($args['from'])) {
            $from = $args['from'];
            if (is_array($from)) {
                $fromAddress = array_keys($from);
                $fromName = array_values($from);
                $this->mailService->getMessage()->setFrom($fromAddress[0], $fromName[0]);
            } else {
                $this->mailService->getMessage()->setFrom($from);
            }
        }

        if (isset($args['cc'])) {
            $this->mailService->getMessage()->setCc($args['cc']);
        }

        if (isset($args['bcc'])) {
            $this->mailService->getMessage()->setBcc($args['bcc']);
        }

        if (isset($args['attachments'])) {
            $this->mailService->setAttachments($args['attachments']);
        }
    }