Skip to content

Instantly share code, notes, and snippets.

@mvrmoreira
Created December 7, 2016 14:34
Show Gist options
  • Save mvrmoreira/3bf1507f19292c5efab20f5e0d3fd47f to your computer and use it in GitHub Desktop.
Save mvrmoreira/3bf1507f19292c5efab20f5e0d3fd47f to your computer and use it in GitHub Desktop.
<?php
// RECEBE OS DADOS DO MEDIDOR
$vazao = $_REQUEST['vazao'];
// TODO: FAZER A LOGICA QUE VAI DECIDIR SE DISPARA OU NAO O EMAIL
// MONTA E CONFIGURA O EMAIL A SER ENVIADO
require 'vendor/autoload.php';
$from = new SendGrid\Email("Example User", "test@example.com");
$subject = "Resultado do Medidor";
$to = new SendGrid\Email("Matheus Moreira", "mvrmoreira@gmail.com");
$content = new SendGrid\Content("text/plain", "Vazão: ".$vazao);
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$apiKey = getenv('SENDGRID_API_KEY');
// DISPARA O EMAIL
$sg = new \SendGrid($apiKey);
$sg->client->mail()->send()->post($mail);
echo "OK";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment