<?php
namespace EasyChat\Library\Email;

final class CmsMailTransport implements OutboundMailTransportInterface {
    private $bridge;
    public function __construct(CmsOutboundMailBridgeInterface $bridge) { $this->bridge = $bridge; }
    public function code(): string { return 'cms_mail'; }
    public function probe(array $config): array {
        $capabilities = $this->bridge->capabilities();
        $ready = CmsMailBridgeHealth::supportsRequiredHeaders($capabilities);
        return array('success'=>$ready,'status'=>$ready?'ready':'error','code'=>$ready?'cms_mail_ready':'cms_mail_headers_unsupported','transport'=>$this->code(),'bridge'=>$this->bridge->code(),'sender_email'=>(string)($capabilities['sender_email']??''),'capabilities'=>$capabilities);
    }
    public function send(array $config, MailEnvelope $mail): array { return $this->bridge->send($mail); }
}
