General error: 1366 Incorrect string value .. for column ..

Created on 6 May 2022, about 2 years ago
Updated 9 August 2023, 11 months ago

I get this error:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1366 Incorrect string value: '\xC7\xEC\x8F\xA2\x0A5...' for column 'mail' at row 1: INSERT INTO {mail_safety_dashboard} (sent, mail) VALUES ........

or this one:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xC7\xEC\x8F\xA2\x0A5...' for column `drupal`.`mail_safety_dashboard`.`mail` at row 1: INSERT INTO {mail_safety_dashboard} (sent, mail) VALUES

and similar.

How can I solve or patch this problem?

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria drupalfan2

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine i-trokhanenko Lutsk πŸ‡ΊπŸ‡¦

    MR #3 - https://git.drupalcode.org/project/mail_safety/-/merge_requests/3.diff solves the issue for me. Thanks for the patch. Making RTBC!

  • πŸ‡§πŸ‡ͺBelgium flyke

    I had this error after updating mail_safety module.

    We programmatically add an attachment to an email via hook_mail.
    Initially we used this bit of code for that:

          $attachment = (object) [
            'filename' => $file->getFilename(),
            'uri' => $file->getFileUri(),
            'filemime' => $file->getMimeType(),
          ];
          $message['params']['files'][] = $attachment;

    After receiving the error, we also tried it like this:
    $message['params']['files'][] = file_get_contents($file->getFileUri());
    And like this:
    $message['params']['files'][] = file_get_contents(\Drupal::service('file_system')->realpath($file->getFileUri()));
    But the error remained.

    I can confirm that MR #3 solves the issue.
    BUT you must uninstall and the reinstall the mail_safety module. This is important for the patch to work as it applies to the hook_install of the module!

  • πŸ‡ΊπŸ‡ΈUnited States TolstoyDotCom L.A.

    I created this for the 8.2 version: https://www.drupal.org/project/mail_safety/issues/3380292 πŸ› Change 'mail' column to be a blob Needs review

Production build 0.69.0 2024