<?php 
	use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;  
	require_once 'PHPMailer_src/Exception.php';
	require_once 'PHPMailer_src/PHPMailer.php';
	require_once 'PHPMailer_src/SMTP.php';
    
	function SendMail($to,$subject,$message,$template_type,$attachment)
	{   
        global $SITE_NAME;
        global $server_url; 
     
        if($template_type==3) //apply job after send mail to applier and job owner
        {
			$from = "noreply@".$server_url;
            
			$header="<!DOCTYPE html>
        	<html lang='en'>
        	  <head>
        		<meta charset='utf-8'>
        		<meta http-equiv='X-UA-Compatible' content='IE=edge'>
        		<meta name='viewport' content='width=device-width, initial-scale=1'>
        		<title>".$subject."</title>
        		<!-- Bootstrap -->
        		<link href='".MAIN_ROOTPATH."/uploads/mail-images/img/bootstrap.min.css' rel='stylesheet'>
        		<style>
        		@media (min-width:320px) and (max-width:480px) {
        .header{width: 100% !important;}
        .view-btn{font-size: 13px !important; padding: 8px !important;}
        .view-btn-2{font-size: 13px !important; padding: 6px 10px !important;}
        .city{width: 250px !important;}
        .app{width: 250px !important;}
        .app img{width: 80px !important;}
        .gap{padding-left: 0px !important; padding-right: 0px !important;}
        .social{width: 180px !important; margin:10px auto !important;}
        .pad{margin-left: 0px !important; margin-right: 0px !important;}
        .copy{width: 100% !important;}
        .poster{display: none;}
        .info-txt h2{margin-left: 0px !important; font-size: 18px !important; text-align: center; margin-top: 17px !important;}
        .info-txt p{margin-left: 0px !important; text-align: center; font-size: 13px !important;}
        .info-txt button{padding: 10px !important; display: block !important; margin: auto !important;}
        .email-box img{float: none !important; margin-bottom: 10px; }
        .email-box button{float: left !important; margin-top: 12px; padding: 12px !important;}
        .email-box h3{font-size: 13px !important;}
        
            }
        
            @media (min-width:481px) and (max-width:767px) {
                .header{width: 100% !important;}
                .city{width: 250px !important;}
                .view-btn{font-size: 13px !important; padding: 10px !important;}
        .view-btn-2{font-size: 13px !important; padding: 9px 12px !important;}
        .app{width: 300px !important; }
        .social{width: 175px !important; }
        ul li{list-style-type: none;}
        
        .poster{display: none;}
        .email-box button{float: left !important; margin-top: 12px; padding: 12px !important;}
        .info-txt h2{margin-left: 0px !important;  text-align: center; margin-top: 35px !important;}
        .info-txt p{margin-left: 0px !important; text-align: center; }
        .info-txt button{padding: 10px !important; display: block !important; margin: auto !important;}
            }
        
        
            @media (min-width:768px) and (max-width:991px) {
                .email-box button{float: left !important; margin-top: 12px;}
            }
        
        
        
            ul {padding-left: 0px; padding-top: 6px;}
            ul li{list-style-type: none; color: #000; font-size: 14px; padding-bottom: 6px;}
        		</style>    
        	</head>
        	<body style='font-family:Open Sans, sans-serif;'>
        			<div class='header'>
        				<div class='container'>
        					<div class='row'>
        						<div class='col-md-12'>
        							<div class='header' style='padding: 20px; background-color: #f1f1f1;border: 3px solid #CCC; width: 650px; margin:20px auto;'>
        								<h2 style='font-size: 24px; font-weight: 800; margin-top: 15px; margin-bottom: 20px;'> <span style='color: #008BCF;'>$SITE_NAME</span></h2>";
    		
    		
    		$footer="<div class='city' style='width: 44%;margin: auto; font-size: 11px; margin-top: 18px;'>
            <p >1000+ Cities &nbsp; |  &nbsp; 70+ Categories &nbsp;  |  &nbsp; 1Cr+ Listings</p>
             </div>
             
        	<div class='app' style='width: 55%; margin: auto; overflow: hidden; margin-top: 15px;'>
        	     <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/play_store.jpg' alt='' style='width: 90px; float: left;'>
        		 <!--<img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (1).gif' alt='' style='width: 90px; float: left;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (4).gif' alt='' class='pad' style='width: 90px; float: left; margin-left: 15px; margin-right: 15px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed.gif' alt='' style='width: 90px; float: left;'>-->
        	</div>     
        	<div class='social' style='width: 32%; margin: auto; overflow: hidden; margin-top: 13px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (5).gif' alt=''  style='width: 28px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (6).gif' alt='' class='gap'  style='width: 28px; margin-left: 5px; margin-right: 5px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (7).gif' alt=''  style='width: 28px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (8).gif' alt='' class='gap'  style='width: 28px; margin-left: 5px; margin-right: 5px;'>
        		 <img src='".MAIN_ROOTPATH."/uploads/mail-images/img/unnamed (9).gif' alt=''  style='width: 28px;'>
        	</div> 
        	<div class='copy' style='width: 80%; margin: auto; margin-top: 25px;'>
             <p style='text-align: center; font-size: 11px; margin-bottom: 4px;'>You are receiving this mail from $SITE_NAME.  <!--You can always <a href='#' style='color: #008BCF; text-decoration: none;'>Unsubscribe</a>--></p>
                           <p style='text-align: center; font-size: 11px; margin-bottom: 4px;'>For any assistance, visit our <a href='#' style='color: #008BCF; text-decoration: none;'>Help Center</a>  or write to us at <a href='#' style='color: #008BCF; text-decoration: none;'>Support@$server_url</a> </p>     
             <p style='text-align: center; font-size: 11px;'>&copy; <a href='#' style='color: #008BCF; text-decoration: none;'>www.$server_url</a></p>
                         </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div> 
             <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'></script>
             <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src='".MAIN_ROOTPATH."/uploads/mail-images/img/bootstrap.min.js'></script>		
             </body>
           </html>";
    		
    		
    		$headers  = "From: $from\r\n";
    		$headers .= "Content-type: text/html\r\n";  
    		
    		$Ticket_data=$header.$message.$footer;
    		/////mail($to,$subject,$Ticket_data,$headers);  
    		/*  // original
			$mail = new PHPMailer;
			$mail->isSMTP();
			$mail->SMTPDebug = 0;
			$mail->Host = "sg3plcpnl0046.prod.sin3.secureserver.net";
			$mail->Port = "465"; // typically 587
			$mail->SMTPSecure = 'ssl'; // ssl is depracated
			$mail->SMTPAuth = true;
			$mail->Username = $mail_username;
			$mail->Password = $mail_password;
			$mail->setFrom("noreply@".$server_url, $SITE_NAME);
			$mail->addAddress($to, "User");
			$mail->Subject = $subject;
			$mail->msgHTML($Ticket_data); // remove if you do not want to send HTML email 
			$mail->send();
			*/
			
			$mail = new PHPMailer;
            $mail->isSMTP();
            $mail->Host = 'localhost';//'sg2nlvphout-v01.shr.prod.sin2.secureserver.net';//'localhost';
            $mail->SMTPAuth = false;
            $mail->SMTPAutoTLS = false; 
            $mail->Port = 25;
            $mail->Username = $mail_username;
            $mail->Password = $mail_password;
            $mail->setFrom("noreply@".$server_url, $SITE_NAME);
            $mail->addAddress($to, "User");
            $mail->Subject = $subject;
            $mail->msgHTML($Ticket_data); // remove if you do not want to send HTML email 
            $mail->send();
        } 
		else if( ($template_type==7) || ($template_type==4) ||($template_type==5) ||($template_type==2) || ($template_type==6) || ($template_type==1)) //gmail registration , Email Verification 
        {  
       
            $from = "noreply@".$server_url;
            $header="<!DOCTYPE html>
            <html lang='en'>
            <head>
            <meta charset='utf-8'>
            <meta http-equiv='X-UA-Compatible' content='IE=edge'>
            <meta name='viewport' content='width=device-width, initial-scale=1'> 
            <title>$subject</title>
            </head>
            <body>
            <div style=' padding: 20px; background-color: #f1f1f1; text-align:left; border: 1px solid #CCC; width: 650px; max-width:100%; margin:20px auto; font-family:Arial, Helvetica, sans-serif; font-size:14px; color:#444'>
            <h2 style='font-size: 22px; display:table; width:100%;vertical-align: middle; font-weight:600; margin-top: 1px; text-align:center; margin-bottom: 20px;'>
            <span style='display:inline-table; height:50px; vertical-align:middle; padding-right:5px;'><img src='".ROOTPATH."/uploads/Emails/logo.png' alt='img' style='width:50px; height:auto;'></span>
            <span style='color: #c70048;display:inline-table; height:50px;vertical-align:middle; line-height:50px; padding-left:5px;'>$SITE_NAME</span></h2><div style='background-color: #fff; width:auto; display:block; padding: 10px 15px 10px; margin-bottom:30px; border: 1px solid #CCC;'>  $message <div style='display:block; width:100%; text-align:center;'>
            <span style='display:inline-block; padding:0 1% 10px; width:30%; min-width:200px'>
            <img src='".ROOTPATH."/uploads/Emails/add3.png' alt='img' style='width:100%'>
            <h2 style='font-size:18px; margin-top:15px; margin-bottom:1px;'>Speedo</h2> 
            <p style='font-size:13px; margin-top:8px;'>Use upto <strong>₹ 2,000 QCash</strong></p>
            </span>
            <span style='display:inline-block; padding:0 1% 10px; width:30%; min-width:200px'>
            <img src='".ROOTPATH."/uploads/Emails/add3.png' alt='img' style='width:100%'>
            <h2 style='font-size:18px; margin-top:15px; margin-bottom:1px;'>Speedo</h2> 
            <p style='font-size:13px; margin-top:8px;'>Use upto <strong>₹ 2,000 QCash</strong></p>
            </span>
            <span style='display:inline-block; padding:0 1% 10px; width:30%; min-width:200px'>
            <img src='".ROOTPATH."/uploads/Emails/add2.png' alt='img' style='width:100%'>
            <h2 style='font-size:18px; margin-top:15px; margin-bottom:1px;'>Speedo</h2> 
            <p style='font-size:13px; margin-top:8px;'>Use upto <strong>₹ 2,000 QCash</strong></p>
            </span>
            
            <span style='display:inline-block; padding:0 0 10px; width:100%; '>
            <img src='".ROOTPATH."/uploads/Emails/add4.png' alt='img' style='width:100%'>
            </span>
            
            </div>
            <div class='city' style='width: 100%; text-align:center; margin: auto; font-size: 11px; margin-top: 18px;'>
            <p><a href='".ROOTPATH."/UserServices/contact_us.php'>Conatct Us</a> &nbsp; |  &nbsp;  <a href='".ROOTPATH."/UserServices/advertise_with_us.php'>Advertise With Us</a> |  &nbsp; <a href='".ROOTPATH."/UserServices/terms_use.php'>Terms Of Use</a></p>
            </div>
            
            <div class='app' style='width: 55%; margin: auto; overflow: hidden; margin-top: 15px; margin-bottom: 17px; text-align:center;'>
            <a href='https://play.google.com/store/apps/details?id=com.laaibhari&hl=en'><img src='".ROOTPATH."/uploads/Emails/play_store.jpg' alt='' style='width: 90px; display:inline-block'></a>
            <!--<img src='".ROOTPATH."/uploads/Emails/unnamed (1).gif' alt='' style='width: 90px; float: left;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed (4).gif' alt='' class='pad' style='width: 90px; float: left; margin-left: 15px; margin-right: 15px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed.gif' alt='' style='width: 90px; float: left;'>-->
            </div>
            
            <div class='social' style='width: 100%; text-align:center; margin: auto; overflow: hidden; margin-top: 13px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed5.gif' alt=''  style='width: 28px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed6.gif' alt='' class='gap'  style='width: 28px; margin-left: 5px; margin-right: 5px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed7.gif' alt=''  style='width: 28px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed8.gif' alt='' class='gap'  style='width: 28px; margin-left: 5px; margin-right: 5px;'>
            <img src='".ROOTPATH."/uploads/Emails/unnamed9.gif' alt=''  style='width: 28px;'>
            </div>
            
            <div class='copy' style='width: 80%; margin: auto; margin-top:15px;'>
            
            <p style='text-align: center; font-size: 13px;font-weight:bold; margin-bottom: 4px;'> <a href='javascript:void(0)' style='color: #c70048; text-decoration: none;'>For assistance write us at support@$server_url</a></p>  
            <p style='text-align: center; font-size: 11px; margin-bottom: 4px;'>Copyright © 2017-2020 $SITE_NAME All rights reserved  </p>     
            <p style='text-align: center; font-size: 11px;font-weight:bold;'> <a href=$Uns>$Home</a></p>
            </div>
            <div class='clearfix'></div>
            </div>
            
            </body>
            </html>"; 
    		
    		$headers  = "From: $from\r\n";
    		$headers .= "Content-type: text/html\r\n";  
    		
    		
    		
    		$Ticket_data=$header;  
    	 
			$mail = new PHPMailer;
            $mail->isSMTP();
            $mail->Host = 'localhost';//'sg2nlvphout-v01.shr.prod.sin2.secureserver.net';//'localhost';
            $mail->SMTPAuth = false;
            $mail->SMTPAutoTLS = false; 
            $mail->Port = 25;
            $mail->Username = $mail_username;
            $mail->Password = $mail_password;
            $mail->setFrom("noreply@".$server_url, $SITE_NAME);
            $mail->addAddress($to, "User");
            $mail->Subject = $subject;
            $mail->msgHTML($Ticket_data); // remove if you do not want to send HTML email 
            $mail->send();
        }  
	}
		
	function SendSMS($mobile,$msg)
	{
		$xml_data ='<?xml version="1.0"?>
		<parent>
		<child>
		<user>KalpanaG</user>
		<key>dacc4ff030XX</key>
		<mobile>'.$mobile.'</mobile>
		<message>'.$msg.'</message>
		<accusage>1</accusage>
		<senderid>LBHARI</senderid>
		</child>
		</parent>'; 		
		 
		$URL = "http://103.233.79.246/submitsms.jsp?";  
		$ch = curl_init($URL);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_ENCODING, 'UTF-8');
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
		curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		$output = curl_exec($ch);
		curl_close($ch);
	}
?>