<?php

    require_once(INCLUDE_PATH.'PHPMailer/PHPMailerAutoload.php');     
    
   
    
	function sendPHPMail($from_name, $from_email, $to_name, $to_email, $subject, $text_message="", $html_message, $attachment1="",$replyto="")
	{
							
			date_default_timezone_set('Etc/UTC'); 
			
			$mail = new PHPMailer();     
			$mail->SMTPDebug = 0;
			$mail->Timeout = 30;	
			$mail->SMTPAuth = true;
			$mail->SMTPSecure = "ssl";
			
			$mail->Host = "gatewayboatingclub.com";   
			$mail->Port = 465; 
			$mail->Username = 'hardwarefair@hardwarefair-india.com'; //$from_email;
			$mail->Password = '3JRs_1ISjG7%';
			
			/*$mail->Host = "smtp.gmail.com";                  
			$mail->Port = 465; 
			$mail->Username = 'salvisaurabh00@gmail.com'; //$from_email;
			$mail->Password = 'salvi.s@30';*/            
			
			$mail-> setFrom($mail->Username,$from_name);    
			
			//Set an alternative reply-to address
			if ($replyto!='')
			{
				$mail-> addReplyTo($replyto, $from_name);
			}
			else
			{			
				$mail-> addReplyTo($from_email, $from_name);
			}	
			//Set who the message is to be sent to
			
			$emailsExploded = explode(",", $to_email);

			//If the array isn't empty, loop through
			if(!empty($emailsExploded))
			{
    			foreach($emailsExploded as $emailAddress)
    			{
        			$mail->AddAddress(trim($emailAddress),$to_name);
    			}
			} 
			else
			{
    			//This should not be the case.
    			throw new Exception('No emails found!');
			}
			
			$mail-> Subject = $subject;
			
			$mail->isHTML(true);                                    // Set email format to HTML

			$mail->msgHTML($html_message); 
			
			$mail->AltBody = $text_message;
			
			if ($attachment1!='')
            {
                $mail->addAttachment($attachment1);
            }
    		//send the message, check for errors
			if (!$mail->send()) {
				echo 'Mailer Error: ' . $mail->ErrorInfo;
			} else {
				//echo 'Message sent!';
				return '1';
			}
			unset($mail);
	}
	