// replace any invalid unicode characters with replacement characters
$params['bounce_reason'] = mb_convert_encoding($params['bounce_reason'], 'UTF-8', 'UTF-8');
+ // dev/mail#37 Replace 4-byte utf8 characaters with the unicode replacement character
+ // while CiviCRM does not support utf8mb4 for MySQL
+ $params['bounce_reason'] = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $params['bounce_reason']);
+
// CRM-11989
$params['bounce_reason'] = mb_strcut($params['bounce_reason'], 0, 254);
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
-SSBhbSBvbiB2YWNhdGlvbiDwn4y0
\ No newline at end of file
+8J+MtCBJIGFtIG9uIHZhY2F0aW9uIPCfjLQ=
\ No newline at end of file