<?php
/**
 * IMPORTANT NOTE
 * The code of this system is closed and a private proprietary of Flex Solutions.
 * A written authorization/license from Flex Solutions is required before using or modifying this code.
 * Email: sales@flexsolution.biz, Phone: +962795342585, Website: http://www.flexsolutions.biz
 */
 

class LSMSMail {

    public static function sendMail($subject, $message, $recipients, $sender=null, $file_path=null, $cc_email=null) {
	Yii::import('application.extensions.phpmailer.JPhpMailer');
	$mail = new JPhpMailer;
	$mail->IsSMTP();   // set mailer to use SMTP
	$mail->SMTPAuth = true;     // turn on SMTP authentication
	$mail->SMTPSecure = Yii::app()->params["email_SMTPSecure"];
	$mail->Host = Yii::app()->params["email_host"];  // specify main and backup server
	$mail->Port = Yii::app()->params["email_port"];
	$mail->Username = Yii::app()->params["email_user_name"];
	$mail->Password = Yii::app()->params["email_password"];
	$mail->CharSet = 'utf-8';
	$mail->SMTPDebug = 0;

	if ($file_path != null)
	    $mail->AddAttachment($file_path);

	$mail->SetFrom(Yii::app()->params["email_set_from_addres"], 'Life Support Management System');
	$mail->Subject = $subject;
	$mail->MsgHTML($message);
	if ($recipients != null)
	    $mail->AddAddress($recipients);
	if ($cc_email != null)
	    if (is_array($cc_email))
		foreach ($cc_email as $email) {
		    $mail->AddCC($email);
		}
	    else
		$mail->AddCC($cc_email);
	try {
	    $mail->Send();
	} catch (Exception $e) {
	    
	}
    }

}

