I have a html contact form and I need to send an email without php. I'm trying to used the mandrill API sending a JSON message. My function calling from the onsubmit is like this, but I'm not recieveing any message to my email.
function send() {
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
"key": "IL_tX9KjtDeZevJkN7YwHA",
"message": {
"text":document.getElementById("message").value,
"subject": "Contacto desde la web",
"from_email":document.getElementById("email").value,
"from_name": document.getElementById("name").value,
"to": [
{
"email": "[email protected]",
"name": "Recipient Name",
"type": "to"
}
]
},
"async": false
}
});
alert("Gracias por ponerte en contacto con nosotros.");
};
Why are you using Ajax with async: false ? You have got to test ajax addìng something like this to your call:
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
You have also to move the success message alert this way:
success: function ( )
{
alert ( " Done ! " );
};
In this way you can understand what is going wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With