Location: PHPKode > projects > Yupi cms > yupi-cms/include/class.yc_mail.php
<?php
/**
 * @author Edin.o
 * @copyright 2009
 */
/*
   Send mail using phpMailer script reading settings from registry   
*/ 
class Yc_Mail
{
   var $fromEmail;
   var $fromName;
   var $sendMethod;
   var $userName;
   var $server;
   var $password;
   var $port;
   var $phpMailer;
   
   function __construct()
   {
      $reg = new Registry();
      $reg->OpenSection("System/Settings/Email");
      
      $items = $reg->GetKeys();
      
      $this->fromEmail = $items["from"];
      $this->server    = $items["server"];
      $this->userName  = $items["username"];
      $this->password  = $items["password"];
      $this->sendMethod= $items["sendmethod"];
      $this->fromName  = $items["fromname"];
      $this->port      = $items["port"];
      
      $this->phpMailer = new PHPMailer();
   }
   
   function SendMail($to, $name, $subject, $body)
   {
      $mail = $this->phpMailer;
      
      if ($this->sendMethod == "sendmail")
      {
         
      }
      if ($this->sendMethod == "smtp")
      {
         $mail->IsSMTP();   
         $mail->SMTPAuth = true;
         $mail->SMTPDebug = 0;
         $mail->Host = $this->server;
         $mail->Port = $this->port;
         $mail->Username = $this->userName;
         $mail->Password = $this->password;
         $mail->SMTPSecure = "tls";
       
      }
     
      $mail->AddAddress($to,$name);
      $mail->From = $this->fromEmail;
      $mail->FromName = $this->fromName;
      $mail->AddReplyTo($this->fromEmail,$this->fromName);
      
      $mail->Subject = $subject;
      $mail->AltBody = $body;
      $mail->MsgHTML($body);
      
      $mail->IsHTML(true);
      $mail->Send();
   } 
}
?>
Return current item: Yupi cms