【发布时间】:2015-07-11 18:39:24
【问题描述】:
我已按照 this 指南使用 JavaScript 和 Mandrill 发送电子邮件,但在我的控制台中收到此错误: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.
这是我的代码:
$('#submitEmail').click(function() {
$.ajax({
type: "POST",
url: "https://mandrillapp.com/api/1.0/messages/send.json",
data: {
'key': 'my_api_key',
'message': {
'from_email': 'test@hotmail.com',
'to': [{
'email': 'test@gmail.com',
'name': 'RECIPIENT NAME (OPTIONAL)',
'type': 'to'
}],
'autotext': 'true',
'subject': 'test',
'html': 'test'
}
}
}).done(function(response) {
console.log(response);
});
});
我做错了什么?
【问题讨论】:
-
请记住,您的 API 密钥对任何人都是可见的,因此任何恶意用户都可能使用您的密钥发送电子邮件,这些电子邮件可能会占用您的配额/垃圾邮件,以至于您的帐户将被阻止
标签: javascript jquery email mandrill