emailClass.php 22.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708
<?php
date_default_timezone_set('Asia/Kolkata');
require 'PHPMailerAutoload.php';
include_once 'helperClass.php';

/**
 * Description of emailClass
 *
 * @author admin
 */
class EmailClass
{
//NOTE : please delete << and >> sign after replacing with actual value

	var $fromname = 'Codename New You';
	var $fromemail = 'marketing@realatte.com';
	var $bcc = array('rohan@realatte.com', 'rahul@realatte.com');
	var $PageUrl = 'Codename New You ';
	var $emailRecipients = array('presales@centuryrealestate.in','chatleads@centuryrealestate.in','dm@centuryrealestate.in','sunil.vattikuti@centuryrealestate.in','siddharth@realatte.com');


    // public function defaultTo() {
    //     return array('marketing@happyheap.com');
    // }

    // public function defaultReplyTo() {
    //   return 'sales@gaganunnatii.com';
    // }

	public function sendMail($params)
	{
		$fromName = $this->fromname;
		$fromEmail = $this->fromemail;
		$bcc = $this->bcc;

		$toEmail = $this->emailRecipients;

        // $replyToEmail = $this->defaultReplyTo();

        //Create a new PHPMailer instance
		$mail = new PHPMailer();

        //Tell PHPMailer to use SMTP
		$mail->isSMTP();

        //Enable SMTP debugging
        // 0 = off (for production use)
        // 1 = client messages
        // 2 = client and server messages
		$mail->SMTPDebug = 0;

        //Ask for HTML-friendly debug output
		$mail->Debugoutput = 'html';

        //Set the hostname of the mail server
        $mail->Host = 'smtp.gmail.com';     // NOTE: for gmail smtp is-> smtp.gmail.com

        //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
        $mail->Port = 587;

        //Set the encryption system to use - ssl (deprecated) or tls
        $mail->SMTPSecure = 'tls';

        //Whether to use SMTP authentication
        $mail->SMTPAuth = true;

        //Username to use for SMTP authentication - use full email address for gmail
        $mail->Username = "centuryrealestatemcc@gmail.com";

        //Password to use for SMTP authentication
        $mail->Password = "hnyvlaffwcqusfnk";

        //Set who the message is to be sent from
        $mail->setFrom($fromEmail, $fromName);

        //Set an alternative reply-to address
        // $mail->addReplyTo($replyToEmail, $fromName);

        //Set who the message is to be sent to
        foreach ($toEmail as $email) {
        	$mail->addAddress($email);
        }

        foreach ($bcc as $email) {
        	$mail->addBCC($email);
        }

        //Set the subject line
        $mail->Subject = $params['subject'];

        //Read an HTML message body from an external file, convert referenced images to embedded,
        //convert HTML into a basic plain-text alternative body
        //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
        $mail->Body = $params['messageBody'];

        //Set to sent content as HTML
        $mail->IsHTML(true);

        //Replace the plain text body with one created manually
        //$mail->AltBody = $params['messageBody'];
        //Attach an image file
        //$mail->addAttachment('images/phpmailer_mini.png');
        //echo "<pre>"; print_r($mail); echo "</pre>";die();
        //send the message, check for errors
        if (!$mail->send()) {
        	echo "Mailer Error: " . $mail->ErrorInfo;
        	echo "<br />";
        	return false;
        } else {
            //echo "Message sent!";
            //header("Location: http://" . $this->defaultUrl . "/thank-you.php");
        	return true;
        }
    }

    public function getLeadDetails()
    {

    	$keyword = $_COOKIE['cstm_ppc_keyword'];
    	$channel = $_COOKIE['cstm_ppc_channel'];
    	$campaign = $_COOKIE['cstm_ppc_campaign'];
    	$placement = $_COOKIE['cstm_ppc_placement'];
    	$device = $_COOKIE['cstm_ppc_device'];
    	$MEDIUM = $_COOKIE['cstm_ppc_medium'];
		$campaign_code = $_COOKIE['campaign_code'];
		$adgroup = $_COOKIE['cstm_ppc_adgroup'];
        $gclid= $_COOKIE['gclid'];

    	$lead = '<tr><td>Keyword:</td><td>' . $keyword . '</td></tr>';
    	$lead .= '<tr><td>Channel:</td><td>' . $channel . '</td></tr>';
    	$lead .= '<tr><td>Campaign:</td><td>' . $campaign . '</td></tr>';
    	$lead .= '<tr><td>Placement:</td><td>' . $placement . '</td></tr>';
    	$lead .= '<tr><td>Device:</td><td>' . $device . '</td></tr>';

    	return $lead;
    }

    public function callback()
    {

    	$keyword = $_COOKIE['cstm_ppc_keyword'];
    	$channel = $_COOKIE['cstm_ppc_channel'];
    	$campaign = $_COOKIE['cstm_ppc_campaign'];
    	$placement = $_COOKIE['cstm_ppc_placement'];
    	$device = $_COOKIE['cstm_ppc_device'];
    	$channel_id = $_COOKIE['channel_id'];
    	$MEDIUM = $_COOKIE['cstm_ppc_medium'];
		$campaign_code = $_COOKIE['campaign_code'];
		$adgroup = $_COOKIE['cstm_ppc_adgroup'];
        $gclid = $_COOKIE['gclid'];

    	$fname = $_REQUEST['fname'];
    	$lname = $_REQUEST['lname'];
    	$email = $_REQUEST['email'];
    	$mobile = str_replace(' ', '', $_REQUEST['mobile']);
    	$source = $_REQUEST['source'];
    	$message = $_REQUEST['message'];
		$country_code = $_REQUEST['country_code'];
    	$dialCode = $_REQUEST['dialCode'];
    	$name = $fname . ' ' . $lname;
    	$full_mob = $dialCode . ' ' . $mobile;
    	$crm_mob = $dialCode . '' . $mobile;

		$userip = $_SERVER['REMOTE_ADDR'];
    	$leadDetails = $this->getLeadDetails();

    

		if ($source == "Download Brochure") {
			$message = "OTP Yes";
		} else {
			$message = "OTP Yes";
		}

		if ($channel == null && $channel == "") {
			$crmchannel = "website";
		} else {
			$crmchannel = $channel;
		}
		// Google Sheet Interation------------------
		$postFields = "entry.449648499=" . $name;
		$postFields .= "&entry.1379833540=" . $email;
		$postFields .= "&entry.758332158=" . $full_mob;
		$postFields .= "&entry.1900106466=" . $userip;
		$postFields .= "&entry.1693361781=" . $source;

		$postFields .= '&entry.1830911442=' . urlencode($_COOKIE['cstm_ppc_campaign']);
		$postFields .= '&entry.939490048=' . urlencode($_COOKIE['cstm_ppc_channel']);
		$postFields .= '&entry.729166844=' . urlencode($_COOKIE['cstm_ppc_keyword']);
		$postFields .= '&entry.839903606=' . urlencode($_COOKIE['cstm_ppc_placement']);
		$postFields .= '&entry.2003337495=' . urlencode($_COOKIE['cstm_ppc_device']);
		$postFields .= '&entry.1156585397=' . $gclid;
		$postFields .= '&entry.1257172821=' . $adgroup;

		$ch1 = curl_init();
		curl_setopt($ch1, CURLOPT_URL, "https://docs.google.com/forms/u/0/d/e/1FAIpQLSeMF3AOf_L-au4Xa0mK-YPT2MZP_w7RDK5cra_7ZKDvcMfSjA/formResponse");
		curl_setopt($ch1, CURLOPT_POST, 1);
		curl_setopt($ch1, CURLOPT_POSTFIELDS, $postFields);
		curl_setopt($ch1, CURLOPT_HEADER, 0);
		curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
		$result1 = curl_exec($ch1);

		
		// New Integration

		 /***********Sale force integration    ********* */
		 
		 
		 $clientIPAddress = $_SERVER['REMOTE_ADDR'];
 
 
		 if ($dialCode == '+91') {
			$Customer_Origin = "Domestic";
		} else {
			$Customer_Origin = "NRI";
		}


		$curl2_new = curl_init();
		curl_setopt_array($curl2_new, array(
			CURLOPT_URL => "https://login.salesforce.com/services/oauth2/token",
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_ENCODING => "",
			CURLOPT_MAXREDIRS => 10,
			CURLOPT_TIMEOUT => 30,
			CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
			CURLOPT_CUSTOMREQUEST => "POST",
			CURLOPT_POSTFIELDS => "client_id=3MVG9fe4g9fhX0E4AD9UQ0IY_YxSm6dhFFUjwXHfxoKoGTvJJQLOPOPZTSqsHAlZny6G3g1JcAdmsYQvoet.j&client_secret=FDB1D47DF7FC917E696BD517DF9F4D485836FC207334CDB0F3F57252B14AC9B7&grant_type=password&username=ashwin.cen%40stetig.in&password=century@123450YaB6VntD39W1UGU3yg1sW1wY",
			CURLOPT_HTTPHEADER => array(
				"cache-control: no-cache",
				"content-type: application/x-www-form-urlencoded"
			),
		));

		$response2_new = curl_exec($curl2_new);
		$json_new = json_decode($response2_new);
		// echo 'token- ' . $json_new->access_token;
		$access_token_new = $json_new->access_token;
		// die;

		if (!$access_token_new == '' || !$access_token_new == null) {


			if ($campaign_code == '' || $campaign_code == null) {
				$campaign_code = 'Google_Search';
			}

			$api_input_new = array(
				'Name' => $name,
				'Mobile' => $mobile,
				"Country_Code" => $dialCode,
				'Email' => $email,
				'Project_Name' => 'Codename',
				'Campaign_Code' => $campaign_code,
				'ChannelPartnerName' => '',
				'Customer_Origin' => $Customer_Origin,
				'Comments' => '',
				"Channel" => $channel,
				"AdGroup" => $adgroup,
				"Keyword" => $keyword,
				"Placement" => $placement,
				"Location" => "Test ",
				"Device" => $device,
				"GCLID" => $gclid,
				"CampaignApi" => $campaign,
				"UserIp" => $clientIPAddress,
				"LpCta" => $source,
			);

			$json_input_new = json_encode($api_input_new);
			// var_dump($api_input_new);

			$curl_new = curl_init();



			curl_setopt_array($curl_new, array(
				CURLOPT_URL => "https://centuryrealestate.my.salesforce.com/services/apexrest/Century/InsertNewEnquiry",
				CURLOPT_RETURNTRANSFER => true,
				CURLOPT_ENCODING => "",
				CURLOPT_MAXREDIRS => 10,
				CURLOPT_TIMEOUT => 30,
				CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST => "POST",
				CURLOPT_POSTFIELDS => $json_input_new,
				CURLOPT_HTTPHEADER => array(
					"authorization: Bearer $access_token_new",
					"cache-control: no-cache",
					"content-type: application/json"
				)
			));

			$response3_new = curl_exec($curl_new);

			// var_dump($response3_new);
			// die;
		}

		// New Integration


		


		/***********Sale force integration    ********* */

		// $clientIPAddress = $_SERVER['REMOTE_ADDR'];

		// if ($dialCode == '+91') {
		// 	$Customer_Origin = "Domestic";
		// } else {
		// 	$Customer_Origin = "NRI";
		// }

		// $curl2 = curl_init();

		// curl_setopt_array($curl2, array(
		// 	CURLOPT_URL => "https://login.salesforce.com/services/oauth2/token",
		// 	CURLOPT_RETURNTRANSFER => true,
		// 	CURLOPT_ENCODING => "",
		// 	CURLOPT_MAXREDIRS => 10,
		// 	CURLOPT_TIMEOUT => 30,
		// 	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		// 	CURLOPT_CUSTOMREQUEST => "POST",
		// 	CURLOPT_POSTFIELDS => "client_id=3MVG9fe4g9fhX0E4AD9UQ0IY_YxSm6dhFFUjwXHfxoKoGTvJJQLOPOPZTSqsHAlZny6G3g1JcAdmsYQvoet.j&client_secret=FDB1D47DF7FC917E696BD517DF9F4D485836FC207334CDB0F3F57252B14AC9B7&grant_type=password&username=ashwin.cen%40stetig.in&password=century@123450YaB6VntD39W1UGU3yg1sW1wY",
		// 	CURLOPT_HTTPHEADER => array(
		// 		"cache-control: no-cache",
		// 		"content-type: application/x-www-form-urlencoded"
		// 		),
		// 	));

		// $response2 = curl_exec($curl2);
		// $json = json_decode($response2);
		// //echo 'token- '.$json->access_token;
		// $access_token = $json->access_token;

		// if (!$access_token == '' || !$access_token == null) {

		// 	// $campaign_code = 'Realatte-Google';
		// 	// if($channel == 'GoogleSearch' || $channel == 'Google'){
		// 	// 	$campaign_code = 'Realatte-Google';
		// 	// }
		// 	// if($channel == 'Facebook'){
		// 	// 	$campaign_code = 'Realatte-Facebook';
		// 	// }

		// 	if($campaign_code == '' || $campaign_code == null){
		// 		$campaign_code = 'Realatte-Google';
		// 	}

		// 	$api_input = array(
		// 		'Name' => $name,
		// 		"Country_Code"=>'+'.$dialCode,
		// 		'Mobile' => $mobile,
		// 		'Email' => $email,
		// 		'Project_Name' => 'Century Novus',
		// 		'Campaign_Code' => $campaign_code,
		// 		'ChannelPartnerName' => '',
		// 		'Customer_Origin' => $Customer_Origin,
		// 		'Comments' => '',
		// 		"Channel"=> $channel,
        //         "AdGroup"=> $adgroup,
        //         "Keyword"=> $keyword,
        //         "Placement"=> $placement,
        //         "Location"=>"Test ",
        //         "Device"=> $device,
        //         "GCLID"=> $gclid,
        //         "CampaignApi"=> $campaign,
        //         "UserIp"=> $clientIPAddress,
        //         "LpCta"=> $source,
		// 		);

		// 	$json_input = json_encode($api_input);

		// 	 // var_dump($json_input);

		// 	$curl = curl_init();

		// 	curl_setopt_array($curl, array(
		// 		CURLOPT_URL => "https://centuryrealestate.my.salesforce.com/services/apexrest/Century/InsertNewEnquiry",
		// 		CURLOPT_RETURNTRANSFER => true,
		// 		CURLOPT_ENCODING => "",
		// 		CURLOPT_MAXREDIRS => 10,
		// 		CURLOPT_TIMEOUT => 30,
		// 		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		// 		CURLOPT_CUSTOMREQUEST => "POST",
		// 		CURLOPT_POSTFIELDS => $json_input,
		// 		CURLOPT_HTTPHEADER => array(
		// 			"authorization: Bearer $access_token",
		// 			"cache-control: no-cache",
		// 			"content-type: application/json"
		// 			)
		// 		));

		// 	$response3 = curl_exec($curl);

		// 	// var_dump($response3);
		// 	// die;

		// }

		// die;

		/***********End of saleforce    ********* */

		


    	if ($source === 'Contact Form') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
    			$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You  Contact Form';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Interest') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
                //$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You  Interest';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Main PopUp') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
                //$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You  Main PopUp';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Price') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
    			$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You  Price';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Brochure') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
    			$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You Brochure';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Virtual Tour') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
    			$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You Virtual Tour';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} elseif ($source === 'Appointment') {

    		if (EmailClass::validationCheckMobile($mobile) === true) {

    			$body = '<html>';
    			$body .= '<body style="font-size: 11; font-family: Verdana;">';
    			$body .= '<h3 style="color:#e91e63;"> Greetings from Codename New You , </h3>';
    			$body .= '<p> Thank you for expressing interest on our website. Our expert will get in touch with you shortly. </p>';
    			$body .= '<br/>';
    			$body .= '<table style="font-size: 11; font-family: Verdana;">';
    			$body .= '<tr><td>Name:</td><td>' . $name . '</td></tr>';
    			$body .= '<tr><td>Email:</td><td>' . $email . '</td></tr>';
    			$body .= '<tr><td>Mobile:</td><td>' . $mobile . '</td></tr>';
    			$body .= '<tr><td>Source:</td><td>' . $source . '</td></tr>';
    			$body .= $leadDetails;
    			$body .= '</table>';
    			$body .= '<br></br>';
    			$body .= 'Regards';
    			$body .= '<br></br>';
    			$body .= $this->fromname;
    			$body .= '<br></br>';
    			$body .= '</body>';
    			$body .= '</html>';
    			$params['messageBody'] = $body;
    			$params['subject'] = 'Codename New You Appointment';

                // Send Mail
    			if ($this->sendMail($params)) {
    				return true;
    			} else {
    				return false;
    			}
    		} else {
    			return false;
    		}
    	} else {
    		return false;
    	}
    }

    public static function validationCheckMobile($mobile)
    {
    	$msg = true;
    	if (empty($mobile) || strlen($mobile) >= 18 || strlen($mobile) <= 3 || $mobile === 'Mobile:' || !(EmailClass::is_mobileNumber($mobile))) {
    		$msg = 'Enter a valid mobile number';
    		return $msg;
    	}
    	return $msg;
    }

    public static function validationCheckEmail($email)
    {
    	$msg = true;
    	if (empty($email) || !(EmailClass::isValidEmail($email)) || $email === 'Email:') {
    		$msg = 'Enter a valid email address';
    		return $msg;
    	}
    	return $msg;
    }

    public static function isValidEmail($email)
    {
        //return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
    	return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email);
    }

    public static function is_mobileNumber($mobile)
    {
    	$regex1 = '123456789';
    	$regex2 = '1234567890';
    	$regex3 = '0123456789';

    	if (preg_match('/^([0-9])\1*$/', $mobile)) {
    		return false;
    	} elseif ($mobile == $regex1) {
    		return false;
    	} elseif ($mobile == $regex2) {
    		return false;
    	} elseif ($mobile == $regex3) {
    		return false;
    	} elseif (preg_match("/[^0-9]/", $mobile)) {
    		return false;
    	} else {
    		return true;
    	}
    }

}

?>