public function saveMailToLogs($params = array())
    {
        if (isset($params['destinataire'])
            && isset($params['sujet'])
            && isset($params['message'])
            && isset($params['debug'])
        ) {
            $debugValue=false;
            if ($params['debug']==true) {
                $debugValue=true;
            }
                
            
            $message = strip_tags($params['message'], '<br>');
            if (file_exists($this->getCheminPhysique().'logs/'.$params['logfile'])) {
                $lastlog = popen(
                    'tac '.escapeshellcmd(
                        $this->getCheminPhysique().
                        'logs/'.$params['logfile']
                    ), 'r'
                );

                $lastline = json_decode(fgets($lastlog));
                pclose($lastlog);
            } else {
                $lastline[3]='';
            }

            if ($lastline[3] == $message) {
                $fn = $this->getCheminPhysique().'/logs/'.$params['logfile'];
                $size = filesize($fn);
                $block = 4096;
                $trunc = max($size - $block, 0);

                $f = fopen($fn, "c+");
                if (flock($f, LOCK_EX)) {
                    fseek($f, $trunc);
                    $bin = rtrim(fread($f, $block), "\n");
                    if ($r = strrpos($bin, "\n")) {
                        ftruncate($f, $trunc + $r + 1);
                    }
                }
                fclose($f);
                error_log(
                    json_encode(
                        array($lastline[0], array_merge(
                            $lastline[1],
                            array($params['destinataire'])
                        ), $params['sujet'], $message)
                    )
                    .PHP_EOL, 3, $this->getCheminPhysique().
                    '/logs/'.$params['logfile']
                );
            } else {
                error_log(
                    json_encode(
                        array(date('c'), array($params['destinataire']),
                        $params['sujet'], $message)
                    ).PHP_EOL, 3, $this->getCheminPhysique().
                    '/logs/'.$params['logfile']
                );
            }
        } else {
            echo "mailObject.class.php : ".
            "sauvegarde dans les logs impossible, il manque un champ.<br>";
        }
    }