Skip to content

Mail sync not working due to charset issue. #13696

Open

Description

@jkladola

Steps to reproduce

  1. while syncing mail account using mail:account:sync <account_id> throwing error like,

Sync failed for 30:INBOX: An exception occurred while executing a query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\xA7\x91\xF0\x9F...' for column nextcloud.oc_mail_messages.subject at row 1

  1. After searching little bit I tried to change charset and collation in database manually and repairing next cloud instance, deleting and recreating mail account, non of it worked.

  2. only after adding "'dbdriveroptions' => array( 1002 => 'SET NAMES utf8mb4 COLLATE utf8mb4_general_ci' )," to nextcloud's config.php. Syncing started working.

So, I guess the issue might be either in mysql configuration is not connecting using utf8mb4 or either the pdo is not connected using utf8mb4.

I have already seen your earlier bug of 2020 but the issue is still persist, may be...

Pardon me for my bad English and/or less knowledge on mysql/pdo connections.

Expected behavior

Now syncing.

Actual behavior

Not Syncing.

Mail app version

5.12.0

Nextcloud version

34.0.4

Mailserver or service

Custom IMAP

Operating system

Debian, turnkey installation

PHP engine version

PHP 8.2

Nextcloud memory caching

Redis

Web server

Apache (supported)

Database

MariaDB

Additional info

No response

Activity

  1. added theissue type on Sep 17, 2026
  2. kesselb commented on Sep 25, 2026

    @kesselb
    Contributor

    Thanks for the report 🙏

    It seems that MariaDB rejects the 4-byte emoji \xF0\x9F\xA7\x91 in oc_mail_messages.subject, which gives the 1366 Incorrect string value error.

    Remove the dbdriveroptions hack and run occ db:convert-mysql-charset. It checks that the database supports utf8mb4, sets mysql.utf8mb4 = true and converts the tables.

  3. self-assigned this
    on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions