arnoldle / phplist-plugin-submitByMailPlugin

Elements of a plugin to submit messages to Phplist by mail. In development. Planning for June release.
3 stars 6 forks source link

Email body truncated on special character when incoming email charset is not UTF-8 #16

Open Vzzbux opened 6 years ago

Vzzbux commented 6 years ago

Incoming emails that have a charset of e.g. iso-8859-1 and include a special character e.g. £ (=A3) are truncated at that point when they're inserted into the database (and therefore when they're sent out on a campaign).

Not sure if this is technically a problem with the mimeDecode.php library or submitByMailPlugin, but I believe it's a problem because of the charset of the MySql database that phplist uses (UTF-8 by default). See this stackoverflow question.

I believe I've managed to fix it within submitByMailPlugin. My last pull request was ignored because the developer no longer supports this plugin, so I'll just include the patch here:

Within submitByMailPlugin.php, alter the following block within the parseAPart() function (roughly line 806):

 if ($c2 == 'plain') {
         $this->textmsg .= $apart->body;
 } else
         $this->htmlmsg .= $apart->body;

to the following:

 $charset = $this->std($apart->ctype_parameters["charset"]);
 $body = $apart->body;
 if (is_string($charset) && strtolower($charset) !== "utf8") $body = iconv($charset, "UTF8", $body);
 if ($c2 == 'plain') {
         $this->textmsg .= $body;
 } else {
         $this->htmlmsg .= $body;
 }