IsSendmail(); } elseif(MAIL_METHOD == 'smtp') { $mail->IsSMTP(); $mail->SMTPDebug = 0; // 0, 1, 2 $mail->Host = MAIL_SMTPHOST; $mail->Port = defined(MAIL_SMTPPORT)? MAIL_SMTPPORT : 25; $mail->SMTPAuth = defined(MAIL_SMTPAUTH)? MAIL_SMTPAUTH : false; $mail->Username = defined(MAIL_SMTPUSER)? MAIL_SMTPUSER : ''; $mail->Password = defined(MAIL_SMTPPASS)? MAIL_SMTPPASS : ''; } //Spécification du charset $mail->CharSet = CHARSET; //Envoi du mail try { $body = $message; $body = eregi_replace("[\]",'',$body); $mail->AddReplyTo($from['email'], $from['name']); $mail->SetFrom($from['email'], $from['name']); foreach($to as $info) { $mail->AddAddress($info['email'], $info['name']); } $mail->Subject = $sujet; $mail->MsgHTML($body); $mail->Send(); return true; } catch (phpmailerException $e) { //Ecriture des erreurs dans un fichier (sujet, to) file_put_contents( PATH_DATA.'/mailerror.log', $e->errorMessage().' '.$to.' '.$sujet, FILE_APPEND ); return false; } }