<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


class mailAction {

public $host;
public $port;
public $username;
public $password;
public $globalSender ;
public $globalName;

    public function  __construct($host, $port, $username, $password, $globalSender, $globalName ){
      $this->host = $host;
	  $this->port = $port;
	  $this->username = $username;
	  $this->password = $password;
	  $this->globalSender = $globalSender;
	  $this->globalName = $globalName;

  
    }

    public function  svaSendMail($to,$ccList,$subject,$body){
		
		//echo "Data ---".$this->host." ".$this->port." ".$this->username." ".$this->password."--Data";  
        $cc=$this->globalSender;
        $mail = new PHPMailer();


        $mail->IsSMTP(); // telling the class to use SMTP
        $mail->Host       = $this->host; // SMTP server
        //$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                                   // 1 = errors and messages
                                                   // 2 = messages only
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
       // $mail->Host       = "mail.absivoire.com"; // sets the SMTP server
        $mail->Port       = $this->port;
        //$mail->Port       = 26;                    // set the SMTP port for the GMAIL server
        $mail->Username   = $this->username; // SMTP account username
        $mail->Password   = $this->password;        // SMTP account password

        $mail->SetFrom($this->globalSender, $this->globalName);

        $mail->AddReplyTo($this->globalSender,$this->globalName);

        $mail->Subject    = $subject;
       // $body= eregi_replace("[\]",'',$body);

        //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

        $mail->MsgHTML($body);

        
        $mail->AddAddress($to, "");
        $mail->AddCC($cc,$this->globalName);

        $ccListCount = count($ccList);

         if($ccListCount>0){

              for($i=0;$i<$ccListCount;$i++){

                  $mail->AddCC($ccList[$i],"");
              }


         }

    
      $status =  $mail->Send();

        
     return $status;
    }






}


?>
