ho seguito this guida su come inviare un'email utilizzando JavaScript con Mandrillo, ma sto ricevendo questo errore nel mio console: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://mandrillapp.com/api/1.0/messages/send.json. This can be fixed by moving the resource to the same domain or enabling CORS.
Come inviare un messaggio di posta elettronica con Mandrill utilizzando JavaScript?
Ecco il mio codice:
$('#submitEmail').click(function() {
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
'key': 'my_api_key',
'message': {
'from_email': '[email protected]',
'to': [{
'email': '[email protected]',
'name': 'RECIPIENT NAME (OPTIONAL)',
'type': 'to'
}],
'autotext': 'true',
'subject': 'test',
'html': 'test'
}
}
}).done(function(response) {
console.log(response);
});
});
Che cosa sto facendo di sbagliato?
Tenete a mente che la vostra chiave API è visibile a chiunque, in modo che qualsiasi utente malintenzionato potrebbe utilizzare la chiave per l'invio di messaggi di posta elettronica in grado di mangiare il vostro quota/spam tante persone che il tuo account verrà bloccato – baao