<?php
require("sendgrid-php/sendgrid-php.php");
include("use.php");

$email='jmcruzd@gmail.com';

$message = "
<html>
<head>
<title>CUENTA ACTIVA</title>
</head>
<body>
<p>Usuario: $email</p>
<p>activado</p>
<table>
<tr>
<th>--</th>
<th>--</th>
</tr>
<tr>
<td></td>
<td>- - - - - - - - - -</td>
</tr>
</table>
<p>Saludos!<br>
productocruz.cl</p>
</body>
</html>
";    

       
$from = new SendGrid\Email('IOT', "noreply@happygo.cl");
$subject = "Confirmacion Cuenta";
$to = new SendGrid\Email(null, $email);
$content = new SendGrid\Content("text/html", $message);
$mail = new SendGrid\Mail($from, $subject, $to, $content);

//$apiKey = getenv($key);
$apiKey = $key;
$sg = new \SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($mail);


   
   if($response->statusCode()==202){
   
    //  print "enviado";
      $msg = 'CUENTA ESTA ACTIVA, REVISA BANDEJA DE CORREO' ;
$msgJson = json_encode($msg);
echo $msgJson ;
      $pdo = null;
      exit;
     
    
   
   }else{
     
   // print ("noenviado"); 
    $msg = 'noenviado' ;
$msgJson = json_encode($msg);
echo $msgJson ;
    $pdo = null;
    exit;

   } 
   
     
     
 //end sending email...   	
 
?>
