Skip to content

Instantly share code, notes, and snippets.

@DaltonWebDev
Created December 3, 2018 13:58
Show Gist options
  • Save DaltonWebDev/fa9dbffddc0774843356692797b430f9 to your computer and use it in GitHub Desktop.
Save DaltonWebDev/fa9dbffddc0774843356692797b430f9 to your computer and use it in GitHub Desktop.
function sendEmail($to, $subject, $from, $content) {
$data = "{\"personalizations\": [ { \"to\": [ { \"email\": \"$to\" } ], \"subject\": \"$subject\" } ], \"from\": { \"email\": \"$from\" }, \"content\": [ { \"type\": \"text/plain\", \"value\": \"$content\" } ] }";
$result = file_get_contents("https://api.sendgrid.com/v3/mail/send", null, stream_context_create(array(
"http" => array(
"method" => "POST",
"header" => "Content-Type: application/json" . "\r\n"
. "Content-Length: " . strlen($data) . "\r\n" . "Authorization: Bearer RETRACTED",
"content" => $data
)
)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment