Get From Addresses.

@param Swift_Mime_Message $message
@return array
489180
protected function getFromAddresses(Swift_Mime_Message $message)
	{
		if ($message->getFrom()) {
			foreach ($message->getFrom() as $address => $name) {
				return [$address, $name];
			}
		}
		return [];
	}
1065344
protected function prepareTo(Swift_Mime_SimpleMessage $message)
    {
        $to = array_map(function ($name, $address) {
            return $name ? $name." <{$address}>" : $address;
        }, $this->combineTo($message), array_keys($this->combineTo($message)));

        return implode(',', $to);
    }
1370359
public function getImagesUrls(array $message)
    {
        return Collection::make($message['message']['attachments'])->where('type',
            'image')->pluck('payload')->map(function ($item) {
                return new Image($item['url'], $item);
            })->toArray();
    }
1245129
public function getMailjetMessage(Swift_Mime_Message $message) {
        $contentType = $this->getMessagePrimaryContentType($message);
        $fromAddresses = $message->getFrom();
        $fromEmails = array_keys($fromAddresses);
        $toAddresses = $message->getTo();
        $ccAddresses = $message->getCc() ? $message->getCc() : [];
        $bccAddresses = $message->getBcc() ? $message->getBcc() : [];

        $attachments = array();
        $inline_attachments = array();

        // Process Headers
        $customHeaders = $this->prepareHeaders($message, $this->getMailjetHeaders());
        $userDefinedHeaders = $this->findUserDefinedHeaders($message);


        // @TODO only Format To, Cc, Bcc
        //@TODO array_push is not recommended
        $to = array();
        foreach ($toAddresses as $toEmail => $toName) {
            if (!is_null($toName)) {
                array_push($to, ['Email' => $toEmail, 'Name' => $toName]);
            } else {
                array_push($to, ['Email' => $toEmail]);
            }
        }
        $cc = array();
        foreach ($ccAddresses as $ccEmail => $ccName) {
            if (!is_null($ccName)) {
                array_push($cc, ['Email' => $ccEmail, 'Name' => $ccName]);
            } else {
                array_push($cc, ['Email' => $ccEmail]);
            }
        }
        $bcc = array();
        foreach ($bccAddresses as $bccEmail => $bccName) {
            if (!is_null($bccName)) {
                array_push($bcc, ['Email' => $bccEmail, 'Name' => $bccName]);
            } else {
                array_push($bcc, ['Email' => $bccEmail]);
            }
        }

        // Handle content
        $bodyHtml = $bodyText = null;
        if ($contentType === 'text/plain') {
            $bodyText = $message->getBody();
        } else {
            $bodyHtml = $message->getBody();
        }


        // Handle attachments
        foreach ($message->getChildren() as $child) {
            if ($child instanceof Swift_Attachment) {
                //Handle regular attachments
                if ($child->getDisposition() === "attachment") {
                    $attachments[] = array(
                        'ContentType' => $child->getContentType(),
                        'Filename' => $child->getFilename(),
                        'Base64Content' => base64_encode($child->getBody())
                    );
                }
                //Handle inline attachments
                elseif ($child->getDisposition() === "inline") {
                    $inline_attachments[] = array(
                        'ContentType' => $child->getContentType(),
                        'Filename' => $child->getFilename(),
                        'ContentID' => $child->getId(),
                        'Base64Content' => base64_encode($child->getBody())
                    );
                }
            } elseif ($child instanceof Swift_MimePart && $this->supportsContentType($child->getContentType())) {
                if ($child->getContentType() == "text/html") {
                    $bodyHtml = $child->getBody();
                } elseif ($child->getContentType() == "text/plain") {
                    $bodyText = $child->getBody();
                }
            }
        }
        $mailjetMessage = array();
        $from = array(
            'Email' => $fromEmails[0],
            'Name' => $fromAddresses[$fromEmails[0]]
        );

        if (!empty($from)) {
            if (is_null($from['Name'])) {
                unset($from['Name']);
            }
            $mailjetMessage['From'] = $from;
        }
        if (!empty($to)) {
            $mailjetMessage['To'] = $to;
        }
        if (!empty($cc)) {
            $mailjetMessage['Cc'] = $cc;
        }
        if (!empty($bcc)) {
            $mailjetMessage['Bcc'] = $bcc;
        }
        if (!is_null($message->getSubject())) {
            $mailjetMessage['Subject'] = $message->getSubject();
        }
        if (!is_null($bodyHtml)) {
            $mailjetMessage['HTMLPart'] = $bodyHtml;
        }
        if (!is_null($bodyText)) {
            $mailjetMessage['TextPart'] = $bodyText;
        }
        if ($replyTo = $this->getReplyTo($message)) {
            $mailjetMessage['ReplyTo'] = $replyTo;
        }

        if (count($userDefinedHeaders) > 0) {
            $mailjetMessage['Headers'] = $userDefinedHeaders;
        }

        if (count($customHeaders) > 0) {
            $mailjetMessage = array_merge($mailjetMessage, $customHeaders);
        }

        if (count($attachments) > 0) {
            $mailjetMessage['Attachments'] = $attachments;
        }
        if (count($inline_attachments) > 0) {
            $mailjetMessage['InlinedAttachments'] = $inline_attachments;
        }


        return array('Messages' => array($mailjetMessage));
    }
1010983
protected function allContacts(Swift_Mime_SimpleMessage $message)
    {
        return array_merge(
            (array) $message->getTo(), (array) $message->getCc(), (array) $message->getBcc()
        );
    }
231169
public function getAudioUrls(array $message)
    {
        return Collection::make($message['message']['attachments'])->where('type',
            'audio')->pluck('payload')->map(function ($item) {
                return new Audio($item['url'], $item);
            })->toArray();
    }
967034
protected function getSchemaForMessage($message)
    {
        // Form schema messages treat simple strings as plain text, so nest for html messages
        $value = $message['message'];
        if ($message['messageCast'] === ValidationResult::CAST_HTML) {
            $value = ['html' => $message];
        }
        return [
            'value' => $value,
            'type' => $message['messageType'],
            'field' => empty($message['fieldName']) ? null : $message['fieldName'],
        ];
    }
1256537
private function buildAttachments(Swift_Mime_Message $message)
    {
        $attachments = [];

        foreach ($message->getChildren() as $part) {
            if ($part instanceof Swift_Attachment) {
                $attachments[] = [
                    'type' => $part->getContentType(),
                    'name' => $part->getFilename(),
                    'data' => base64_encode($part->getBody()),
                ];
            }
        }

        return $attachments;
    }
600425
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
    {
        if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
            $this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
            if ($evt->bubbleCancelled()) {
                return 0;
            }
        }

        $this->doSend($message, $failedRecipients);

        if ($evt) {
            $evt->setResult(\Swift_Events_SendEvent::RESULT_SUCCESS);
            $this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
        }

        $count = (
            count((array) $message->getTo())
            + count((array) $message->getCc())
            + count((array) $message->getBcc())
        );

        return $count;
    }
64389
private function preparePayload(Message $message): array
    {
        $payload = [
            'text' => $message->getText(),
            'channel' => $message->getChannel(),
            'username' => $message->getUsername(),
            'link_names' => $this->options['link_names'] ? 1 : 0,
            'unfurl_links' => $this->options['unfurl_links'],
            'unfurl_media' => $this->options['unfurl_media'],
            'mrkdwn' => $this->options['allow_markdown'],
        ];

        if ($icon = $message->getIcon()) {
            $payload[$message->getIconType()] = $icon;
        }

        $payload['attachments'] = $this->getAttachmentsAsArrays($message);

        return $payload;
    }
105358
private function parseMessage($message)
    {
        $string = $message;

        if (is_array($message)) {
            $format = '"%s" %s';
            $errors = array();

            foreach ($message as $field => $messages) {
                if (is_array($messages)) {
                    $messages = array_unique($messages);
                    foreach ($messages as $error) {
                        $errors[] = sprintf($format, $field, $error);
                    }
                } elseif (is_integer($field)) {
                    $errors[] = $messages;
                } else {
                    $errors[] = sprintf($format, $field, $messages);
                }
            }

            $string = implode(', ', $errors);
        }

        return $string;
    }
937259
protected function getPreviewFilePath(Swift_Mime_SimpleMessage $message)
    {
        $to = str_replace(['@', '.'], ['_at_', '_'], array_keys($message->getTo())[0]);

        $subject = $message->getSubject();

        return $this->previewPath.'/'.str_slug($message->getDate()->getTimestamp().'_'.$to.'_'.$subject, '_');
    }
62054
public function getRecipients()
    {
        // get sender address
        $headers = $this->message->headers();
        $to      = rcube_mime::decode_address_list($headers['To'], null, false, null, true);
        $cc      = rcube_mime::decode_address_list($headers['Cc'], null, false, null, true);
        $bcc     = rcube_mime::decode_address_list($headers['Bcc'], null, false, null, true);

        $recipients = array_unique(array_merge($to, $cc, $bcc));
        $recipients = array_diff($recipients, array('undisclosed-recipients:'));

        return $recipients;
    }
281034
private function getHeaders(PushMessage $message) : array
    {
        return [
            'Authorization' => 'key='.$this->apiKey,
            'Content-Type' => 'application/json',
            'Content-Length' => $message->getContentLength(),
            'Encryption' => 'keyid=p256dh;salt='.$message->getSalt(),
            'Crypto-Key' => 'keyid=p256dh;dh='.$message->getCryptoKey(),
            'Content-Encoding' => 'aesgcm',
            'TTL' => $message->getTTL(),
        ];
    }
602372
private function buildPayload(Swift_Mime_Message $message)
    {
        try {
            return $this->payloadBuilder->buildPayload($message);
        } catch (AnyException $exception) {
            throw $this->createAndDispatchTransportException(
                'Failed to build payload for a SparkPost transmission',
                $exception
            );
        }
    }
1221406
private function readUserContentType(Swift_Mime_Message $message)
    {
        $ro = new \ReflectionObject($message);
        $rp = $ro->getProperty('_userContentType');
        $rp->setAccessible(true);
        return (string) $rp->getValue($message);
    }
579600
protected function attachments(SlackMessage $message)
    {
        return collect($message->attachments)->map(function ($attachment) use ($message) {
            return array_filter([
                'actions' => $attachment->actions,
                'author_icon' => $attachment->authorIcon,
                'author_link' => $attachment->authorLink,
                'author_name' => $attachment->authorName,
                'color' => $attachment->color ?: $message->color(),
                'fallback' => $attachment->fallback,
                'fields' => $this->fields($attachment),
                'footer' => $attachment->footer,
                'footer_icon' => $attachment->footerIcon,
                'image_url' => $attachment->imageUrl,
                'mrkdwn_in' => $attachment->markdown,
                'pretext' => $attachment->pretext,
                'text' => $attachment->content,
                'thumb_url' => $attachment->thumbUrl,
                'title' => $attachment->title,
                'title_link' => $attachment->url,
                'ts' => $attachment->timestamp,
            ]);
        })->all();
    }