A Mailhandler importer on one of my sites recently started failing. The mailbox was being checked, but no nodes were created, and I got this error message:

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF0\x9F\x98\x8A.p...' for column 'filename' at row 1

I've tracked the problem down to a message in the mailbox that had an Outlook Emoji png in the message body. When I run the import, the emoji image file gets saved to the mailhandler_temp folder, but emoji character code in the filename apparently can't be saved into the file_managed table. The filename in the mailhandler_temp folder shows up for me as OutlookEmoji-[a rectangular box displays where the emoji code is].png

I suspect that the solution is to patch /plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php, but I don't know what changes need to be made to the code.

In the meantime, I removed that message from the mailbox, and all other messages were imported successfully.

Comments

brianbrarian created an issue.

brianbrarian’s picture

I found a quick-and-dirty fix that worked for my problem message. In MailhandlerCommandsFiles.class.php I changed line 21 from:

if ($attachment->filename !== 'unnamed_attachment') {

to
if ($attachment->filename !== 'unnamed_attachment' && strpos($attachment->filename,'Emoji') !== false) {

Something more robust is probably needed for a real solution, though.