public static function replaceBinaryStrings($message)
    {
        $lines = explode("\r\n", $message);

        foreach ($lines as &$line) {
            if (!mb_check_encoding($line, 'utf-8')) {
                $line = '<' . strlen($line) . ' bytes binary content>';
            }
        }

        return implode("\r\n", $lines);
    }