public function encodeHeader($str, $position = 'text') {
        $encoded = core_text::encode_mimeheader($str, $this->CharSet);
        if ($encoded !== false) {
            if ($position === 'phrase') {
                // Escape special symbols in each line in the encoded string, join back together and enclose in quotes.
                $chunks = preg_split("/\\n/", $encoded);
                $chunks = array_map(function($chunk) {
                    return addcslashes($chunk, "\0..\37\177\\\"");
                }, $chunks);
                return '"' . join(parent::getLE(), $chunks) . '"';
            }
            return str_replace("\n", parent::getLE(), $encoded);
        }

        return parent::encodeHeader($str, $position);
    }
public function encodeHeader($str, $position = 'text') {
        $encoded = core_text::encode_mimeheader($str, $this->CharSet);
        if ($encoded !== false) {
            if ($position === 'phrase') {
                // Escape special symbols in each line in the encoded string, join back together and enclose in quotes.
                $chunks = preg_split("/\\n/", $encoded);
                $chunks = array_map(function($chunk) {
                    return addcslashes($chunk, "\0..\37\177\\\"");
                }, $chunks);
                return '"' . join(parent::getLE(), $chunks) . '"';
            }
            return str_replace("\n", parent::getLE(), $encoded);
        }

        return parent::encodeHeader($str, $position);
    }
public function encodeHeader ( $ str , $ position = 'text' ) { $ encoded = core_text :: encode_mimeheader ( $ str , $ this -> CharSet ) ; if ( $ encoded !== false ) { if ( $ position === 'phrase' ) { // Escape special symbols in each line in the encoded string, join back together and enclose in quotes. $ chunks = preg_split ( "/\\n/" , $ encoded ) ; $ chunks = array_map ( function ( $ chunk ) { return addcslashes ( $ chunk , "\0..\37\177\\\"" ) ; } , $ chunks ) ; return '"' . join ( parent :: getLE ( ) , $ chunks ) . '"' ; } return str_replace ( "\n" , parent :: getLE ( ) , $ encoded ) ; } return parent :: encodeHeader ( $ str , $ position ) ; }
Use internal moodles own core_text to encode mimeheaders.
Fall back to phpmailers inbuilt functions if not
Use internal moodles own core_text to encode mimeheaders . Fall back to phpmailers inbuilt functions if not