<?php
/*SendGrid Library*/
require_once ('vendor/autoload.php');

/*Post Data*/
$email = $_POST['email'];

/*Content*/
$from = new SendGrid\Email("Vault Logic", "no-reply@vaultlogic.com");
$subject = "New Sign-Up";
$to = new SendGrid\Email("Weldon", "info@vaultlogic.com");
$content = new SendGrid\Content("text/html", "Your new subscriber is " . $email);

/*Send the mail*/
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = ('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');
$sg = new \SendGrid($apiKey);

/*Response*/
$response = $sg->client->mail()->send()->post($mail);
?>

<!--Print the response-->
<pre>
    <?php
    var_dump($response);
    ?>
</pre>

<?php header("Location: /thank-you.html"); ?>
