CP1250 character encoding not working / unable to read mails encoded with CP1250

Nextcloud version 25.0.2.3
Operating system and version Ubuntu 22.04
Apache 2.4.52
PHP version 8.1 (fpm)

The issue you are facing:
Nextcloud mail is not able to show the content of messages sent with CP1250 / windows 1250 character encoding.

Is this the first time you’ve seen this error? (Y/N): Partly (earlier very few messages were not visible in nextcloud mail. Now there are several of those not shown messages)

Steps to replicate it:

  1. Open nextcloud mail
  2. Click on received message
  3. Mail is showing only blank message with header visible (sender, topic etc,) no message body text

The output of your Nextcloud log in Admin > Logging:


[mail] Error: Exception: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "cp1250" in file '/var/www/nextcloud/apps/mail/lib/Model/IMAPMessage.php' line 661 at <<closure>>

0. /var/www/nextcloud/lib/private/AppFramework/App.php line 172
   OC\AppFramework\Http\Dispatcher->dispatch()
1. /var/www/nextcloud/lib/private/Route/Router.php line 298
   OC\AppFramework\App::main()
2. /var/www/nextcloud/lib/base.php line 1047
   OC\Route\Router->match()
3. /var/www/nextcloud/index.php line 36
   OC::handleRequest()

GET /index.php/apps/mail/api/messages/50633/body

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

$CONFIG = array (
  'instanceid' => '-',
  'passwordsalt' => '-',
  'secret' => '-',
  'trusted_domains' => 
  array (
-
  ),
  'datadirectory' => '-',
  'dbtype' => 'mysql',
  'version' => '25.0.2.3',
  'overwrite.cli.url' => '-',
  'htaccess.RewriteBase' => '/',
  'overwritehost' => '-',
  'overwritewebroot' => '/',
  'overwriteprotocol' => 'https',
  'dbname' => '-',
  'dbhost' => '-',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '-',
  'dbpassword' => '-',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '-',
    'port' => -,
    'password' => '-',
    'timeout' => 1.5,
  ),
  'mail_from_address' => '-',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '-',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '-',
  'mail_smtpport' => '-',
  'mail_smtpname' => '-',
  'mail_smtppassword' => '-',
  'mail_smtpsecure' => '-',
  'default_phone_region' => '-',
  'default_locale' => '-',
  'default_language' => '-',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 0,
  'updater.release.channel' => 'stable',
  'app_install_overwrite' => 
  array (
    0 => '-',
  ),
);