private function getAddressesFromFieldInPart($field, Part $part)
    {
        $addresses = [];

        $headers = $part->getHeaders();
        if (empty($headers)) {
            return $addresses;
        }

        if (!$headers->has($field)) {
            return $addresses;
        }

        /** @var AbstractAddressList $addressList */
        $addressList = null;

        try {
            $addressList = $part->getHeader($field);
        } catch (InvalidArgumentException $e) {
            return $addresses;
        }

        if (!$addressList instanceof AbstractAddressList) {
            return $addresses;
        }

        foreach ($addressList->getAddressList() as $address) {
            $addresses[] = strtolower($address->getEmail());
        }

        return $addresses;
    }
private function getAddressesFromFieldInPart($field, Part $part)
    {
        $addresses = [];

        $headers = $part->getHeaders();
        if (empty($headers)) {
            return $addresses;
        }

        if (!$headers->has($field)) {
            return $addresses;
        }

        /** @var AbstractAddressList $addressList */
        $addressList = null;

        try {
            $addressList = $part->getHeader($field);
        } catch (InvalidArgumentException $e) {
            return $addresses;
        }

        if (!$addressList instanceof AbstractAddressList) {
            return $addresses;
        }

        foreach ($addressList->getAddressList() as $address) {
            $addresses[] = strtolower($address->getEmail());
        }

        return $addresses;
    }
private function getAddressesFromFieldInPart ( $ field , Part $ part ) { $ addresses = [ ] ; $ headers = $ part -> getHeaders ( ) ; if ( empty ( $ headers ) ) { return $ addresses ; } if ( ! $ headers -> has ( $ field ) ) { return $ addresses ; } /** @var AbstractAddressList $addressList */ $ addressList = null ; try { $ addressList = $ part -> getHeader ( $ field ) ; } catch ( InvalidArgumentException $ e ) { return $ addresses ; } if ( ! $ addressList instanceof AbstractAddressList ) { return $ addresses ; } foreach ( $ addressList -> getAddressList ( ) as $ address ) { $ addresses [ ] = strtolower ( $ address -> getEmail ( ) ) ; } return $ addresses ; }
Retrieves the addresses from a specific field in a part

@param string $field
@param Part   $part

@return array
Retrieves the addresses from a specific field in a part