/**
  * @inheritDoc
  */
 public static function toWrappedMessage($message, $transport = null)
 {
     if (!$message instanceof Message) {
         throw new MailWrapperSetupException('Invalid Message');
     }
     $wrappedMessage = new MailWrappedMessage();
     $wrappedMessage->setWrappedMessage($message);
     $subject = $message->getSubject();
     $contentHtml = $message->getBody();
     $contentText = $message->getBodyText();
     $toRecipients = $message->getTo();
     $ccRecipients = $message->getCc();
     $bccRecipients = $message->getBcc();
     $from = $message->getFrom()->current();
     $replyTo = $message->getReplyTo()->current();
     $wrappedMessage->setFrom($from);
     $wrappedMessage->setReplyTo($replyTo);
     $wrappedMessage->setSubject($subject);
     $wrappedMessage->setContentText($contentText);
     $wrappedMessage->setContentHtml($contentHtml);
     foreach ($toRecipients as $address) {
         $wrappedMessage->addToRecipient($address->getEmail());
     }
     foreach ($ccRecipients as $address) {
         $wrappedMessage->addCcRecipient($address->getEmail());
     }
     foreach ($bccRecipients as $address) {
         $wrappedMessage->addBccRecipient($address->getEmail());
     }
     return $wrappedMessage;
 }
 /**
  * @inheritDoc
  */
 public static function toWrappedMessage($message)
 {
     if (!$message instanceof MessageBuilder) {
         throw new MailWrapperSetupException('Invalid Message');
     }
     $wrappedMessage = new MailWrappedMessage();
     $wrappedMessage->setWrappedMessage($message);
     $mailgunMessageArray = $message->getMessage();
     if (array_key_exists('from', $mailgunMessageArray)) {
         foreach ($mailgunMessageArray['from'] as $address) {
             $wrappedMessage->setFrom($address);
         }
     }
     if (array_key_exists('to', $mailgunMessageArray)) {
         foreach ($mailgunMessageArray['to'] as $address) {
             $wrappedMessage->addToRecipient($address);
         }
     }
     if (array_key_exists('cc', $mailgunMessageArray)) {
         foreach ($mailgunMessageArray['cc'] as $address) {
             $wrappedMessage->addCcRecipient($address);
         }
     }
     if (array_key_exists('bcc', $mailgunMessageArray)) {
         foreach ($mailgunMessageArray['bcc'] as $address) {
             $wrappedMessage->addBccRecipient($address);
         }
     }
     if (array_key_exists('subject', $mailgunMessageArray)) {
         $wrappedMessage->setSubject($mailgunMessageArray['subject']);
     }
     if (array_key_exists('text', $mailgunMessageArray)) {
         $wrappedMessage->setContentText($mailgunMessageArray['text']);
     }
     if (array_key_exists('html', $mailgunMessageArray)) {
         $wrappedMessage->setContentHtml($mailgunMessageArray['html']);
     }
     if (array_key_exists('h:reply-to', $mailgunMessageArray)) {
         $wrappedMessage->setReplyTo($mailgunMessageArray['h:reply-to']);
     }
     return $wrappedMessage;
 }