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);