Subject Line Missing from Inbound Emails

After testing I found another issue relevant, when the subjects are in other encoding like “GBK”, so I modified the code a little bit, as below:

public function handleMimeHeaderDecode($subject)
    {
        $subjectDecoded = $this->getImap()->MimeHeaderDecode($subject);
		$ret = '';
		if(!is_array($subjectDecoded)){
			// regex to extract all the MIME parts (Like GBK)
			preg_match_all("/=\?[^?]+\?[B|Q]\?[^?]+\?=/", $subjectDecoded, $matches);
			if (!empty($matches[0])) {
				$allEncodedParts = array_merge(...$matches);
				foreach ($allEncodedParts as $part) {
				//decode the GBK MIME
					$ret.= mb_decode_mimeheader($part);
				}
				return $ret;
			} else {
				return $subjectDecoded;
			}
		}
        foreach ($subjectDecoded as $object) {
            if ($object->charset != 'default') {
                $ret .= $this->handleCharsetTranslation($object->text, $object->charset);
            } else {
                $ret .= $object->text;
            }
        }

        return $ret;
    }