Changeset 1017

Show
Ignore:
Timestamp:
04/10/06 14:57:34 (7 years ago)
Author:
dana
Message:

Added PHPMailer libraries into /include
Updated Mail.php to make use of PHPMailer library to enable configuration of how email is sent (SMTP, Auth, etc).
Added 5 settings to config.php to enable configuration of PHPMailer

Location:
trunk/wifidog-auth/wifidog
Files:
2 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/wifidog/classes/Mail.php

    r1013 r1017  
    5050 * @copyright  2005-2006 Francois Proulx, Technologies Coeus inc. 
    5151 */ 
     52 
     53require_once('include/class.phpmailer.php'); 
     54require_once('include/class.smtp.php'); 
     55 
    5256class Mail 
    5357{ 
     
    308312        public function send() 
    309313        { 
    310         if ($this->getRecipientName() != "") { 
    311             $headers  = "To: \"" . $this->getRecipientName() . "\" <" . $this->getRecipientEmail() . ">\r\n"; 
    312             } 
    313  
    314                 $headers  = "From: \"" . $this->getSenderName() . "\" <" . $this->getSenderEmail() . ">\r\n"; 
    315                 $headers .= "Reply-To: " . $this->getSenderEmail() . "\r\n"; 
    316                 $headers .= "Content-Type: text/plain; charset=utf-8"; 
    317  
    318                 if (defined("WIFIDOG_NAME")) { 
    319                   $headers .= "\r\n" . "X-Mailer: " . WIFIDOG_NAME . defined("WIFIDOG_VERSION") ? "/" . WIFIDOG_VERSION : ""; 
    320                 } 
    321  
    322                 $args = "-f" . $this->getSenderEmail(); 
    323  
    324                 return mail($this->getRecipientEmail(), $this->getMessageSubject(), $this->getMessageBody(), $headers, $args); 
     314        $mail = new PHPMailer(); 
     315        $mail->CharSet = "utf-8"; 
     316         
     317        $mail->Mailer = EMAIL_MAILER;         
     318        if (EMAIL_MAILER == 'smtp') { 
     319            $mail->Host = EMAIL_HOST; 
     320            $mail->SMTPAuth = EMAIL_AUTH; 
     321 
     322            if (EMAIL_AUTH) { 
     323                $mail->Username = EMAIL_USERNAME; 
     324                $mail->Password = EMAIL_PASSWORD; 
     325            } 
     326        } 
     327         
     328        $mail->AddAddress($this->getRecipientEmail(), $this->getRecipientName()); 
     329        $mail->From = $this->getSenderEmail(); 
     330        $mail->FromName = $this->getSenderName(); 
     331        $mail->Sender = $this->getSenderEmail(); // add Sender Name 
     332        $mail->Subject = $this->getMessageSubject(); 
     333        $mail->Body = $this->getMessageBody(); 
     334 
     335        $result = $mail->Send(); 
     336        if (!$result) { 
     337            print $mail->ErrorInfo; 
     338        } 
     339        return $result; 
    325340        } 
    326341 
  • trunk/wifidog-auth/wifidog/config.php

    r1013 r1017  
    323323// define('WIFIDOG_LOGFILE', 'tmp/wifidog.log'); 
    324324 
     325 /** 
     326  * Email configuration 
     327  * =============================== 
     328  * 
     329  * Internal configuration values for WiFiDog - don't touch! 
     330  */ 
     331 
     332define('EMAIL_MAILER', 'mail'); // "mail", "sendmail", or "smtp" 
     333   
     334// Valid only for SMTP 
     335define('EMAIL_HOST', ''); 
     336define('EMAIL_AUTH', false); 
     337 
     338// Valid if EMAIL_AUTH is true 
     339define('EMAIL_USERNAME', ''); 
     340define('EMAIL_PASSWORD', ''); 
     341 
    325342/** 
    326343 * In case this is the local.config.php you should remove the next lines.