protected function parseSubject($subject)
    {
        $subject = imap_mime_header_decode($subject);

        $subjectParts = array_map(function ($subj) {
            if (strtolower($subj->charset) === 'default') {
                return $subj->text;
            }
            return iconv($subj->charset, static::$charset, $subj->text);
        }, $subject);

        return implode('', $subjectParts);
    }