. */ /* */ /*************************************************************************************/ require_once __DIR__ . "/../fonctions/autoload.php"; require_once(__DIR__ . "/../lib/phpMailer/class.phpmailer.php"); class Mail extends PHPMailer{ function __construct(){ $this->LE = "\n"; } public function AddrFormat($addr) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $formatted = $this->SecureHeader($addr[0]); } else{ if(empty($addr[1])) { $formatted = $this->SecureHeader($addr[0]); } else { $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; } } return $formatted; } /* * Un helper pour creer un mailer simplement */ public static function creermailer() { $mailclient = new Mail(); $smtp = new Smtpconfig(1); if($smtp->active) { $mailclient->IsSMTP(); $mailclient->Host = $smtp->serveur; $mailclient->Port = ($smtp->port!="")?$smtp->port:25; if($smtp->username != "") { $mailclient->SMTPAuth = true; $mailclient->Username = $smtp->username; $mailclient->Password = $smtp->password; $mailclient->SMTPSecure = ($smtp->secure != "")?$smtp->secure:""; } } else { $mailclient->IsMail(); } return $mailclient; } /* * Un helper pour envoyer un mail simple simplement */ public static function envoyer ( $to_name, $to_address, $from_name, $from_address, $subject, $msg_html, $msg_text) { $mailclient = self::creermailer(); $mailclient->FromName = utf8_decode($from_name); $mailclient->From = $from_address; $mailclient->AddAddress($to_address, utf8_decode($to_name)); $mailclient->Subject = utf8_decode($subject); if (empty($msg_html)) { $mailclient->Body = utf8_decode($msg_text); } else { $mailclient->MsgHTML(utf8_decode($msg_html)); $mailclient->AltBody = utf8_decode($msg_text); } return $mailclient->send(); } } ?>