public function getEmailMessages($to = '')
    {
        // Update address for checking.
        if (!empty($to) && $this->email !== $to) {
            $this->email = $to;
        }

        if (empty($this->messages[$this->email])) {
            $messages = self::hasTag('imap')
              ? $this->getMessagesViaImap($this->email)
              : $this->getMessagesFromDb();

            if (empty($messages)) {
                throw new \RuntimeException(sprintf('The message for "%s" was not sent.', $this->email));
            }

            foreach ($messages as &$message) {
                if ($message['to'] === $this->email) {
                    $message['links'] = $this->parseLinksText($message['body']);
                }
            }

            $this->messages[$this->email] = $messages;
        }

        // The debug messages may differ due to testing testing mode:
        // Drupal mail system collector or IMAP protocol.
        self::debug(['%s'], [var_export($this->messages[$this->email], true)]);

        return $this->messages[$this->email];
    }
public function getEmailMessages($to = '')
    {
        // Update address for checking.
        if (!empty($to) && $this->email !== $to) {
            $this->email = $to;
        }

        if (empty($this->messages[$this->email])) {
            $messages = self::hasTag('imap')
              ? $this->getMessagesViaImap($this->email)
              : $this->getMessagesFromDb();

            if (empty($messages)) {
                throw new \RuntimeException(sprintf('The message for "%s" was not sent.', $this->email));
            }

            foreach ($messages as &$message) {
                if ($message['to'] === $this->email) {
                    $message['links'] = $this->parseLinksText($message['body']);
                }
            }

            $this->messages[$this->email] = $messages;
        }

        // The debug messages may differ due to testing testing mode:
        // Drupal mail system collector or IMAP protocol.
        self::debug(['%s'], [var_export($this->messages[$this->email], true)]);

        return $this->messages[$this->email];
    }
@param string $to

@throws \RuntimeException

@return array