<?php
 require_once "includes/recaptchalib.php"; 
// your secret key
$secret = "6LdRE2AUAAAAABxyYNIfnx1dXCINs_EXwKbQhVG8";
 
// empty response
$response = null;
 
// check secret key
$reCaptcha = new ReCaptcha($secret);


//print_r($_POST); die();

$captcha = $_POST['g-recaptcha-response'];
    $toEmail = "corpaccounts@merchantproinc.com";
    //$toEmail = "kripa@codeatech.com";
    
   
    $mailHeaders = "From: " . $_POST["email"] ."\r\n";
    $mailHeaders .= "MIME-Version: 1.0\r\n";
    $mailHeaders .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
    $subject = "Send Updates";
   
    
    $message = '<html><body>';
    $message .= "<p>Send latest processing updates.</p>";
    $message .= "<table rules='all' cellpadding='10' cellspacing='0' height='100%' width='500px' style='border : none;'>";
    $message .= "<tr><td style='border: none;'><strong>Email:</strong> </td><td style='border: none;'>" . strip_tags($_POST['email']) . "</td></tr>";
    $message .= "</table>";
    $message .= "</body></html>";








// if submitted check response
if (!empty($captcha)) {
    $response = $reCaptcha->verifyResponse(
        $_SERVER["REMOTE_ADDR"],
        $captcha
    );
    
    if ($response != null && $response->success) {
        if(mail($toEmail, $subject, $message, $mailHeaders)) {
            $message =  "<p class='success'>Thank you for Joining us.</p>";
            $res = array('status' => 'success', 'message' => $message);
        } else {
            $message = "<p class='Error'>Something went wrong. Please try again later.</p>";
            $res = array('status' => 'error', 'message' => $message);
        }
    }else{
        $message = "<p class='Error'>Something went wrong. Please try again later.</p>";
        $res = array('status' => 'error', 'message' => $message);
    }
}else{
    $message = "<p class='Error'>Verify reCaptcha</p>";
    $res = array('status' => 'error', 'message' => $message);
}

echo json_encode($res);

    
    
    
?>