File: /var/www/nclive/backend/home_subscription_email.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
require '/var/www/html/cronss/PHPMailer-master/PHPMailerAutoload.php';
function random_strings($length_of_string)
{
$str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
return substr(str_shuffle($str_result),0, $length_of_string);
}
$json = file_get_contents('php://input');
$data = json_decode($json);
$email = $data->email_id;
$encodedEmail = rtrim(strtr(base64_encode($email), '+/', '-_'), '=');
$shuffle = random_strings(7);
$backShuffle = random_strings(6);
$encode = $shuffle.$encodedEmail.$backShuffle;
$link = "http://naukriconnect.com/complete-verification?";
$message = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<body style="background-color:#ecf0f1">
<div align="center" style="background-color:#cbd7da;">
<table id="email-penrose-conteneur" width="625" align="center" style="padding:20px 0px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="625" class="resp-full-table" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" style="text-align:center;">
<img src="http://naukriconnect.com/images/naukriconnect-logo.png" alt="Logo" border="0" style="width:20%;">
</td>
</tr>
</table>
</td>
</tr>
</table>
<table id="email-penrose-conteneur" width="625" align="center" style="border-right:1px solid #e2e8ea; border-bottom:1px solid #e2e8ea; border-left:1px solid #e2e8ea; background-color:#ffffff;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="background-color:#481F79">
<table width="625" class="resp-full-table" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="resp-full-td" valign="top" style="padding:20px; text-align:center;">
<span style="font-size:20px; font-family:verdana; font-weight:100; color:#ffffff">Getting Started with NaukriConnect </span>
</td>
</tr>
<tr>
<td width="100%" class="resp-full-td" valign="top" style="padding: 0px 20px 20px 20px;">
<table align="center" border="0" cellspacing="0" cellpadding="0" style="margin:auto; padding:auto;">
<tr>
<td style="background-color:#ffffff; border-radius:3px; padding: 10px 40px;font-family: verdana;text-align: center;text-decoration: none;display: block;color: #55555a;font-weight: bold;font-size: 25px;">
Welcome to NaukriConnect
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" valign="top">
<table align="center" border="0" cellspacing="0" cellpadding="0" style="margin:auto; padding:auto;">
<tr>
<td style="text-align:center; padding:0px 10px 10px 10px;">
<a href="#"><img style="cursor:default;width:100%;border-radius:10px;" src="http://naukriconnect.com//images/naukriconnect-bg.png" class="email-penrose-img-header" alt="Cadeau" border="0" style="display:block;width:100%;border-radius:10px;"></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #e2e8ea">
<table width="625" class="resp-full-table" align="center" border="0" cellspacing="0" cellpadding="0" style="padding:20px;">
<tr>
<td width="100%">
<table width="555" class="resp-full-table" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="resp-full-td" valign="top" style="text-align : justify;">
<span style="font-size:15px; font-weight: bold; font-family:verdana; color:#55555a;">Verify Your Email Address to start getting latest information related to government exams.</span><br />
<hr align="left" style="width:100px; margin-left:0px; text-align:left; background-color:#481F79; color:#481F79; height: 2px; border: 0 none;" />
<span style="font-size:16px; font-family:verdana; color:#313131">You’re on your way to getting emails from NaukriConnect! The first step is to verify your email address. Please click the link or paste the URL into your web browser.<br /><br /><a href="'.$link.$encode.'" target="_blank" style="text-decoration: none;font-weight: 600;font-size: 14px;line-height: 1.5;
}">'.$link.$encode.'</a></span>
</td>
</tr>
<tr>
<td width="100%" class="resp-full-td" valign="top" style="padding-top:20px;">
<table align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="background-color:#481F79; border-radius:3px; padding: 6px 24px;font-family:verdana; color:#ffffff; text-align: center; text-decoration: none; display:block; font-weight : 200; font-size: 16px;">
<a href="'.$link.$encode.'" target="_blank" style="text-decoration: none;color:#fff;">Verify Email address</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table width="625" class="resp-full-table" align="center" border="0" cellspacing="0" cellpadding="0" style="padding:20px;">
<tr>
<td width="100%">
<table width="615" align="left" class="resp-full-table" style="background-color:#481F79; border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="resp-full-td" valign="top" style="text-align: center; padding:20px;">
<span style="font-size:25px; font-weight: bold; font-family:verdana; color:#ffffff;">
<img src="http://naukriconnect.com/images/naukriconnect-logo.png" alt="Logo" border="0" style="width:20%;"></span><br />
<hr align="left" style="width:100%; margin-left:0px; text-align:left; background-color:#ffffff; color:#ffffff; height: 2px; border: 0 none;" />
<span style="font-size:16px; font-family:verdana; color:#ffffff;"><a href="http://naukriconnect.com/" target="_blank" style="color: #fff;text-decoration: none;">naukriconnect.com</a> | <a href="http://naukriconnect.com/about-us" target="_blank" style="color: #fff;text-decoration: none;">about us</a> | <a href="http://naukriconnect.com/privacy-policy" target="_blank" style="color: #fff;text-decoration: none;">privacy policy</a></span>
<hr align="left" style="width:50%; margin-left:145px; text-align:left; background-color:#ffffff; color:#ffffff; height: 2px; border: 0 none;" />
<span style="color:#fff;">
<a href="https://www.facebook.com/officialnaukriconnect/" target="_blank" title="Official facebook page"><img src="http://naukriconnect.com/images/facebook.png" alt="Facebook" border="0" style="width:6%;margin-bottom: -10px!important;"></a> <a href="https://twitter.com/naukriconnect" target="_blank" title="Official twitter page"><img src="http://naukriconnect.com/images/twitter-new.png" alt="Twitter" border="0" style="width:6%;margin-bottom: -10px!important;"></a>
</span>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table id="email-penrose-conteneur" width="600" align="center" style="padding:20px 0px;" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="600" class="resp-full-table" align="center" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" class="resp-full-td" style="text-align: center;"><span style="font-size:12px; font-family:verdana; color:#55555a">NaukriConnect.com © 2019 All Rights Reserved <!--| <a href="https://www.facebook.com/officialnaukriconnect/" target="_blank" title="Official facebook page"><img src="http://naukriconnect.com/images/facebook.png" alt="Facebook" border="0" style="width:5%;margin-bottom: -10px!important;"></a> <a href="https://twitter.com/naukriconnect" target="_blank" title="Official twitter page"><img src="http://naukriconnect.com/images/twitter.png" alt="Twitter" border="0" style="width:5%;margin-bottom: -10px!important;"></a>---></span>
<hr align="left" style="margin-left:0px; text-align:left; background-color:#55555a; color:#55555a; height: 1px; border: 0 none;" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>';
//echo $message;
// $resultArrayData = array();
// $checkExistQuery = "select count(*) as total from sp_subscription where email_id='$email'";
// $sqlExist=$db->prepare($checkExistQuery);
// $sqlExist->execute();
// $rowExist=$sqlExist->fetch();
// $exist = $rowExist['total'];
// if($exist==0){
// $insertQuery = "insert into sp_subscription set email_id='$email', status='1'";
// $sqlInsert=$db->prepare($insertQuery);
// $sqlInsert->execute();
// $resultArrayData[]=array("status"=>1, "message"=>'You have successfully subscribed for Naukri Connect');
// } else {
// $resultArrayData[]=array("status"=>0, "message"=>'This email id already exist');
// }
// echo json_encode($resultArrayData);
$checkExistQuery = "select count(*) as total from sp_subscription where email_id='$email'";
$sqlExist=$db->prepare($checkExistQuery);
$sqlExist->execute();
$rowExist=$sqlExist->fetch();
$exist = $rowExist['total'];
if($exist==0)
{
//$message = "Hello Checking phpmailer";
$subject = "Verify Email Address for NaukriConnect";
$fromname = "info@naukriconnect.com";
$mail = new PHPMailer();
$mail->IsSMTP(true); // SMTP
$mail->SMTPAuth = true; // SMTP authentication
$mail->SMTPSecure = 'tls';
$mail->Mailer = "smtp";
$mail->SMTPDebug = false;
$mail->CharSet="utf-8";
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
$mail->Host = "email-smtp.us-east-1.amazonaws.com"; // Amazon SES server, note "tls://" protocol
$mail->Port = 587; // set the SMTP port
$mail->Username = "AKIAJNZIE3YHYSQAT3YA"; // SES SMTP username
$mail->Password = "Av2k8J06PNIv9ZCX46bP0n9r8oo78/F9tO3GXdxTwqcx";
$mail->SetFrom($fromname , 'Naukri Connect');
$mail->AddReplyTo($fromname , 'Naukri Connect');
$mail->Subject = $subject;
$mail->MsgHTML($message);
$mail->AddAddress($email, $email);
$mail->Send();
{
$insertQuery = "insert into sp_subscription set email_id='$email', status='0'";
$sqlInsert=$db->prepare($insertQuery);
$sqlInsert->execute();
}
$resultArrayData[]=array("status"=>1, "message"=>'Thanks for connecting with Naukri Connect! A verification email has been sent to your email id, please verify your email id to receive notifications.');
}
else
{
$resultArrayData[]=array("status"=>0, "message"=>'This email id already exist');
}
echo json_encode($resultArrayData);
?>