Emoji in subject line

I found some 5 year old information about emoticons in the subject line … you can do it like this
=?utf-8?Q?=F0=9F=8E=BE_Wanless_Tennis_News?=

That works for the final email.
However it’s a bit of a drag that it doesn’t work in the PHPList interface.

Things I tried:

  • 1.Change the characterset and collation of the DB tables. Did not try applying to the entire database.
ALTER TABLE phplist_message CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE phplist_messagedata CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    1. tried different bitmasks on the htmlentities call on line 662 of send_core.php. Going further eliminate the htmlentities altogether to eliminate that as a concern.

Still if you type an emoji directly into the subject line in the composition interface it will disappear when you save it. The displayed error is

Database error 1366 while doing query Incorrect string value: '\xF0\x9F\x8E\xBE =...' for column mynewsdb.phplist_messagedata.data` at row 1

Is there any way to support this feature other than the ugly hack at the top?

@jimlongo You need to ALTER the particular columns of the message and messagedata tables that you want to hold utf8mb4. So the subject column of message table and the data column of messagedata.

Also need to change a line in admin/mysqli.inc to use utf8mb4

mysqli_query($db, "SET NAMES 'utf8'");

Thank you @duncanc

To confirm, I have run the following mysql statements.

ALTER TABLE phplist_message CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE phplist_message MODIFY subject VARCHAR(255) CHARACTER SET utf8mb4;
ALTER TABLE phplist_messagedata CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE phplist_messagedata MODIFY data LONGTEXT CHARACTER SET utf8mb4;

And added to (not changed) the admin/mysql.inc file to look like this

<?php

mysqli_query($db, "SET NAMES 'utf8'");
include __DIR__ . '/mysqli.inc';

also tried utf8mb in this mysql.inc file.

There is no error when saving the campaign.

However, in both cases I end up with a subject of (no title) in the message table, and in messagedata table there is no name='subject' for this message.

@jimlongo You have misunderstood
You need to change the line in admin/mysqli.inc

mysqli_query($db, "SET NAMES 'utf8'");

to

mysqli_query($db, "SET NAMES 'utf8mb4'");

Thank you. That worked.

You might want to edit your original post which referred to the wrong file.

@jimlongo Ah, sorry for that, now fixed.
Also my other suggestion regarding altering the columns is unnecessary. Altering the table also changes text columns, which I had thought wasn’t the case.

Thanks again.
Wouldn’t this be a “feature” that should be in the core and updates?

1 Like