private function adaptMessage(Message $message, array $to, array $cc, array $bcc): Swift_Message
    {
        $swiftMessage = new Swift_Message($message->subject(), null, $message->content()->mimeType());
        $cids = $this->moveAttachments($message, $swiftMessage);
        $swiftMessage->setBody(str_replace(array_keys($cids), $cids, $message->content()));

        if ($message->content()->asPlainText()) {
            $swiftMessage->addPart($message->content()->asPlainText(), 'text/plain');
        }

        $swiftMessage->setTo(array_merge($this->adaptAddresses($message->to()), $this->adaptAddresses($to)));
        $swiftMessage->setCc(array_merge($this->adaptAddresses($message->cc()), $this->adaptAddresses($cc)));
        $swiftMessage->setBcc(array_merge($this->adaptAddresses($message->bcc()), $this->adaptAddresses($bcc)));
        $swiftMessage->setSender($this->adaptAddresses([$message->sender()]));
        $swiftMessage->setFrom($this->adaptAddresses($message->from()));

        return $swiftMessage;
    }
private function adaptMessage(Message $message, array $to, array $cc, array $bcc): Swift_Message
    {
        $swiftMessage = new Swift_Message($message->subject(), null, $message->content()->mimeType());
        $cids = $this->moveAttachments($message, $swiftMessage);
        $swiftMessage->setBody(str_replace(array_keys($cids), $cids, $message->content()));

        if ($message->content()->asPlainText()) {
            $swiftMessage->addPart($message->content()->asPlainText(), 'text/plain');
        }

        $swiftMessage->setTo(array_merge($this->adaptAddresses($message->to()), $this->adaptAddresses($to)));
        $swiftMessage->setCc(array_merge($this->adaptAddresses($message->cc()), $this->adaptAddresses($cc)));
        $swiftMessage->setBcc(array_merge($this->adaptAddresses($message->bcc()), $this->adaptAddresses($bcc)));
        $swiftMessage->setSender($this->adaptAddresses([$message->sender()]));
        $swiftMessage->setFrom($this->adaptAddresses($message->from()));

        return $swiftMessage;
    }
private function adaptMessage ( Message $ message , array $ to , array $ cc , array $ bcc ) : Swift_Message { $ swiftMessage = new Swift_Message ( $ message -> subject ( ) , null , $ message -> content ( ) -> mimeType ( ) ) ; $ cids = $ this -> moveAttachments ( $ message , $ swiftMessage ) ; $ swiftMessage -> setBody ( str_replace ( array_keys ( $ cids ) , $ cids , $ message -> content ( ) ) ) ; if ( $ message -> content ( ) -> asPlainText ( ) ) { $ swiftMessage -> addPart ( $ message -> content ( ) -> asPlainText ( ) , 'text/plain' ) ; } $ swiftMessage -> setTo ( array_merge ( $ this -> adaptAddresses ( $ message -> to ( ) ) , $ this -> adaptAddresses ( $ to ) ) ) ; $ swiftMessage -> setCc ( array_merge ( $ this -> adaptAddresses ( $ message -> cc ( ) ) , $ this -> adaptAddresses ( $ cc ) ) ) ; $ swiftMessage -> setBcc ( array_merge ( $ this -> adaptAddresses ( $ message -> bcc ( ) ) , $ this -> adaptAddresses ( $ bcc ) ) ) ; $ swiftMessage -> setSender ( $ this -> adaptAddresses ( [ $ message -> sender ( ) ] ) ) ; $ swiftMessage -> setFrom ( $ this -> adaptAddresses ( $ message -> from ( ) ) ) ; return $ swiftMessage ; }
Adapt the given message to a Swift message.

@param Message $message
@param EmailAddress[] $to List of recipients which will be merged with those set in the message.
@param EmailAddress[] $cc List of recipients of the message copy which will be merged with those set in the message.
@param EmailAddress[] $bcc List of recipients who this message will be blind-copied to which will be merged with those set in the message.

@return Swift_Message
Adapt the given message to a Swift message .