protected function getMail($matches = [], $new = false, $index = null, $store = 'default')
    {
        $mail = $this->getMailManager()->getMail($store);
        $previousMailCount = $this->getMailCount($store);
        $this->mailCount[$store] = count($mail);

        // Ignore previously seen mail.
        if ($new) {
            $mail = array_slice($mail, $previousMailCount);
        }

        // Filter mail based on $matches; keep only mail where each field mentioned
        // in $matches contains the value specified for that field.
        $mail = array_values(array_filter($mail, function ($singleMail) use ($matches) {
            return ($this->matchesMail($singleMail, $matches));
        }));

        // Return an individual mail if specified by an index.
        if (is_null($index) || count($mail) === 0) {
            return $mail;
        } else {
            return array_slice($mail, $index, 1)[0];
        }
    }
protected function getMail($matches = [], $new = false, $index = null, $store = 'default')
    {
        $mail = $this->getMailManager()->getMail($store);
        $previousMailCount = $this->getMailCount($store);
        $this->mailCount[$store] = count($mail);

        // Ignore previously seen mail.
        if ($new) {
            $mail = array_slice($mail, $previousMailCount);
        }

        // Filter mail based on $matches; keep only mail where each field mentioned
        // in $matches contains the value specified for that field.
        $mail = array_values(array_filter($mail, function ($singleMail) use ($matches) {
            return ($this->matchesMail($singleMail, $matches));
        }));

        // Return an individual mail if specified by an index.
        if (is_null($index) || count($mail) === 0) {
            return $mail;
        } else {
            return array_slice($mail, $index, 1)[0];
        }
    }
protected function getMail ( $ matches = [ ] , $ new = false , $ index = null , $ store = 'default' ) { $ mail = $ this -> getMailManager ( ) -> getMail ( $ store ) ; $ previousMailCount = $ this -> getMailCount ( $ store ) ; $ this -> mailCount [ $ store ] = count ( $ mail ) ; // Ignore previously seen mail. if ( $ new ) { $ mail = array_slice ( $ mail , $ previousMailCount ) ; } // Filter mail based on $matches; keep only mail where each field mentioned // in $matches contains the value specified for that field. $ mail = array_values ( array_filter ( $ mail , function ( $ singleMail ) use ( $ matches ) { return ( $ this -> matchesMail ( $ singleMail , $ matches ) ) ; } ) ) ; // Return an individual mail if specified by an index. if ( is_null ( $ index ) || count ( $ mail ) === 0 ) { return $ mail ; } else { return array_slice ( $ mail , $ index , 1 ) [ 0 ] ; } }
Get collected mail, matching certain specifications.

@param array $matches
Associative array of mail fields and the values to filter by.
@param bool $new
Whether to ignore previously seen mail.
@param null|int $index
A particular mail to return, e.g. 0 for first or -1 for last.
@param string $store
The name of the mail store to get mail from.

@return \stdClass[]
An array of mail, each formatted as a Drupal 8
\Drupal\Core\Mail\MailInterface::mail $message array.
Get collected mail matching certain specifications .