Skip to content

Instantly share code, notes, and snippets.

@dbarjs
Created August 4, 2016 18:01
Show Gist options
  • Save dbarjs/d22b07a78a210f24f6cc5765550caac4 to your computer and use it in GitHub Desktop.
Save dbarjs/d22b07a78a210f24f6cc5765550caac4 to your computer and use it in GitHub Desktop.
var data = JSON.stringify({
"personalizations": [
{
"to": [
{
"email": "joseeduardobarros@gmail.com"
}
],
"subject": "Hello, World!"
}
],
"from": {
"email": "mailman@elbit.com.br"
},
"content": [
{
"type": "text",
"value": "Olá, mundo"
}
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api.sendgrid.com/v3/mail/send");
xhr.setRequestHeader("authorization", "Bearer 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");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("postman-token", "3acd8f0c-b544-b8b1-5507-79737757243e");
xhr.send(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment