smtp_code_ex bad encoding

add `mb_convert_encoding` convert
This commit is contained in:
nenge123 2024-03-12 11:00:23 +08:00 committed by GitHub
parent 5251d33124
commit b16108172e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -4192,6 +4192,15 @@ class PHPMailer
$msg .= ' ' . $this->lang('smtp_code') . $lasterror['smtp_code'];
}
if (!empty($lasterror['smtp_code_ex'])) {
if(function_exists('mb_detect_encoding')):
$charset = strtoupper(ini_get('default_charset'));
if($charset):
$encoding = mb_detect_encoding($lasterror['smtp_code_ex'],array($charset,'GB18030','CP936','UTF-8'),true);
if($encoding&&$charset != $encoding):
$lasterror['smtp_code_ex'] = mb_convert_encoding($lasterror['smtp_code_ex'],$charset,$encoding);
endif;
endif;
endif;
$msg .= ' ' . $this->lang('smtp_code_ex') . $lasterror['smtp_code_ex'];
}
}