protected function format(MessageInterface $message)
    {
        $headers = [];
        foreach ($message->getHeaders() as $name => $value) {
            $headers[] = ['Name' => $name, 'Value' => $value];
        }

        $parameters = [
            'From'     => $this->buildIdentityString($message->getFrom()),
            'To'       => $this->buildIdentityString($message->getTo()),
            'Subject'  => $message->getSubject(),
            'Headers'  => $headers,
            'HtmlBody' => $message->getHtml(),
            'TextBody' => $message->getText(),
            'ReplyTo'  => $message->getReplyTo(),
        ];

        if ($message instanceof TaggableInterface) {
            $tag = $message->getTag();

            if (is_array($tag)) {
                $tag = reset($tag);
            }

            $parameters['Tag'] = $tag;
        }

        if ($message instanceof AttachmentsAwareInterface) {
            $attachments = $this->processAttachments($message->getAttachments());

            if ($attachments) {
                $parameters['Attachments'] = $attachments;
            }
        }

        return json_encode(array_filter($parameters));
    }
protected function format(MessageInterface $message)
    {
        $headers = [];
        foreach ($message->getHeaders() as $name => $value) {
            $headers[] = ['Name' => $name, 'Value' => $value];
        }

        $parameters = [
            'From'     => $this->buildIdentityString($message->getFrom()),
            'To'       => $this->buildIdentityString($message->getTo()),
            'Subject'  => $message->getSubject(),
            'Headers'  => $headers,
            'HtmlBody' => $message->getHtml(),
            'TextBody' => $message->getText(),
            'ReplyTo'  => $message->getReplyTo(),
        ];

        if ($message instanceof TaggableInterface) {
            $tag = $message->getTag();

            if (is_array($tag)) {
                $tag = reset($tag);
            }

            $parameters['Tag'] = $tag;
        }

        if ($message instanceof AttachmentsAwareInterface) {
            $attachments = $this->processAttachments($message->getAttachments());

            if ($attachments) {
                $parameters['Attachments'] = $attachments;
            }
        }

        return json_encode(array_filter($parameters));
    }
{@inheritdoc}