I get the following error every time I sent a simplenews newsletter with mimemail enabled since the latest upgrade to 6.x-1.0-alpha6:

warning: mb_convert_encoding() [function.mb-convert-encoding]: Illegal character encoding specified in sites/all/modules/mimemail/modules/mimemail_compress/mimemail_compress.inc on line 65.

Comments

sgabe’s picture

First, print out the $encoding variable to see its value. Second, try to replace it with 'auto' and let the mb_convert_encoding() function decide which encoding to use.

$body = mb_convert_encoding($body, 'HTML-ENTITIES', 'auto');

stella’s picture

Status: Active » Needs review
StatusFileSize
new561 bytes

Attached patch fixes the warning - mb_detect_encoding() was returning false but this return value wasn't checked before calling mb_convert_encoding()

sgabe’s picture

Status: Needs review » Needs work

Maybe the warning is gone, but this skips the encoding entirely. Would you try with "auto" if the detection fails?

stella’s picture

I did try it with 'auto' if the detection fails, but then I get the exact same error for that line. Perhaps 'auto' is not the correct param name.

sgabe’s picture

I can't see your post with the revised patch, but I got the notification message...

stella’s picture

StatusFileSize
new649 bytes

here it is again, but it doesnt work

sgabe’s picture

Is the CSS Compressor still functional without the encoding?

nmweb’s picture

I'm seeing a similar error after upgrading to this mimemail version:

Fatal error: Call to undefined function mb_detect_encoding() in .../sites/all/modules/mimemail/modules/mimemail_compress/mimemail_compress.inc on line 64

The same error appears after changing the encoding as indicated in comment #1.

Has anyone found a way to fix the error? Thanks in advance.

LJ

sgabe’s picture

Title: error after upgrading to 6.x-1.0-alpha6 » Check if body encoding can be, and is it successfully detected
Status: Needs work » Needs review
StatusFileSize
new1.26 KB

I am attaching a patch to check if the necessary functions exist and the encoding is successfully detected. Note that I only set the encoding of the DOMDocument if all is fine.

Please test it and report back.

sgabe’s picture

Status: Needs review » Fixed

Committed to HEAD.

stella’s picture

thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pslcbs’s picture

Hello,
my newsletters (simplenews) before applying the patch from #10 were good with no errors on special characters on the emails but getting the warnings after sending it

warning: mb_convert_encoding() [function.mb-convert-encoding]: Illegal character encoding specified in sites/all/modules/mimemail/modules/mimemail_compress/mimemail_compress.inc on line 65.

After applying the patch (same results with 6.x-1.0-alpha7 and 6.x-1.0-alpha8 versions) I don't see the warnings but the emails are full of strange characters as I show on the attached files.

Thanks for your help

sgabe’s picture

I think the filenames of the images are wrong, because the image WITH the patch shows that everything is fine.

First, we should know what is the encoding that throws this error. You can use the Devel module to see what is happening. Just add the below line after $encoding = mb_detect_encoding($body); and report back with the result.

dpm($encoding, "detected character encoding");