nextcloud / nextcloud/mail

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'message_id' at row 1

Open
#9,102 11 comments 0 reactions 1 assignee View on GitHub

@kesselb is already working on this.

Since Oct 8, 2025.

1. to develop bug
Dominant language
JavaScript
Stars
1k
Forks
348
Avg merge
12h 28m
Merged PRs (30d)
91

Description

Steps to reproduce

@ChristophWurst, as follow-up to #3154, I still get a OCA\Mail\Exception\ServiceException: Sync failed for 7:Junk: An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'message_id' at row 1 in my Spam folder with Mail 3.4.4 on Nextcloud 27.1.4.

message_id in oc_mail_messages is varchar(1023) with utf8mb4_bin.

I guess there are spam mails that don't follow the spec. 😓

  1. Try to open (Spam) mail folder in Nextcloud Mail
  2. New mails will not be shown
  3. Look at logs to get exception
[mail] Error: OCA\Mail\Exception\ServiceException: Sync failed for 7:Junk: An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'message_id' at row 1 at <<closure>>

0. /var/www/html/custom_apps/mail/lib/Service/Sync/SyncService.php line 120
   OCA\Mail\Service\Sync\ImapToDbSynchronizer->sync("*** sensitive parameters replaced ***")
1. /var/www/html/custom_apps/mail/lib/Controller/MailboxesController.php line 153
   OCA\Mail\Service\Sync\SyncService->syncMailbox("*** sensitive parameters replaced ***")
2. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 230
   OCA\Mail\Controller\MailboxesController->sync("*** sensitive parameters replaced ***")
3. /var/www/html/lib/private/AppFramework/Http/Dispatcher.php line 137
   OC\AppFramework\Http\Dispatcher->executeController(["OCA\\Mail\\Con ... "], "sync")
4. /var/www/html/lib/private/AppFramework/App.php line 183
   OC\AppFramework\Http\Dispatcher->dispatch(["OCA\\Mail\\Con ... "], "sync")
5. /var/www/html/lib/private/Route/Router.php line 315
   OC\AppFramework\App::main("OCA\\Mail\\Cont ... r", "sync", ["OC\\AppFramewo ... "], ["95","mail.mailboxes.sync"])
6. /var/www/html/lib/base.php line 1068
   OC\Route\Router->match("/apps/mail/api/mailboxes/95/sync")
7. /var/www/html/index.php line 36
   OC::handleRequest()
Expected behavior

Show new mails in the folder.

Actual behavior

New mails will not be shown

Mail app version

3.4.4

Mailserver or service

https://github.com/docker-mailserver/docker-mailserver

Operating system

Linux (Docker)

PHP engine version

PHP 8.2

Web server

Apache (supported)

Database

MariaDB

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.