Skip to content

Instantly share code, notes, and snippets.

@kurai021
Created July 5, 2017 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurai021/77d0eaafb7cc6886452473cbec0d8fee to your computer and use it in GitHub Desktop.
Save kurai021/77d0eaafb7cc6886452473cbec0d8fee to your computer and use it in GitHub Desktop.
function sendmail(){
var name = document.getElementById("name").value;
var lastname = document.getElementById("lastname").value;
var email = document.getElementById("email").value;
var phone = document.getElementById("phone").value;
var country = document.getElementById("country").value;
var project = document.getElementById("project").value;
var contact = "Email";
var comment = document.getElementById("comments").value;
$.ajax({
url: "https://api.sendgrid.com/v3/mail/send.json",
type: 'POST',
beforeSend: function(request, settings) {
request.setRequestHeader("Authorization", 'bearer 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');
},
data: {
"personalizations": [{
"to": [{
"email": "samahel021@gmail.com"
}]
}],
"from": {
"email": email
},
"subject": "Contacto",
"content": [{
"type": "text/plain",
"value": "<p>Nombre: " + name + " " + lastname + "</br>" + "Teléfono: " + phone + "</br>" + "País: " + country + "</br>" + "Proyecto de interés: " + project + "</br>" + comment + "</p>"
}]
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment