<?php
 
	class mail{
		
		public static function send( $to , $subject , $msg , $from , $from_name = false , $reply = false , $reply_name = false ){
			global $tpl;
            
			$msg = $tpl->fetch('tpl/email/header.tpl') . $msg;
            $msg.= $tpl->fetch('tpl/email/footer.tpl');
            
    		if(mail( $to , $subject , $msg , mail::headerSTD( $from , $from_name , $reply = false , $reply_name = false ))) return true;
    		else return false;
		}

		public static function headerSTD( $from , $from_name = false , $reply = false , $reply_name = false ){
			$headers = "X-Priority: 1\r\n";
			$headers .= "X-MSMail-Priority: High\r\n";
			$headers .= "Content-type: text/html; charset=utf-8 \r\n";
			$headers .= "MIME-Version: 1.0 \r\n";	
			
			if(!$from_name) $from_name = $from;
			if(!$reply_name) $reply_name = $reply;

			$headers .= "From: \"". $from_name ."\" <". $from .">\r\n";	
			$headers .= ($reply and $reply_name) ? ("Reply-To: \"". $reply ."\" <". $reply_name .">\r\n") : '';
						
				return $headers;		
		}		
	}


?>