我最近開始使用Mandrill進行客戶端電子郵件發送。客戶端的網站不使用任何服務器端程序,因此每個邏輯都必須位於客戶端。如何從客戶端使用Mandrillapp API?
我現在是工作在Chrome,火狐,IE10,但不是在LTE IE9,也不是Android 4.0 <既不IOS:\
m = new mandrill.Mandrill("APIKEY", true)
m.call "messages/send", {
message:
html: createHtml()
subject: "subj"
from_email: "[email protected]",
from_name: "From",
to: [
email: "[email protected]"
name: "User"
]
}, (()->
console.log "success"
@
),()->
console.log "error"
@
在這段代碼中,我使用JS Mandrill API wrapper,但我用jQuery ajax POST-ing試了一下,我得到了同樣的結果。
jQuery的版本:
$.ajax
type: "POST"
url: "https://mandrillapp.com/api/1.0/messages/send.json"
data:
key: "APIKEY"
message:
html: createHtml()
subject: "subject"
from_email: "[email protected]",
from_name: "From",
to: [
email: "[email protected]"
name: "User"
]
誰能幫我出,如何解決跨域API調用來山魈?
謝謝,稍後當我回家時我會檢查它:) Btw。我使用jQuery 1.10.2,所以這不應該是一個問題。使用Mandrill,您可以指定要允許電子郵件發送的IP,因此「黑客」只能從同一個站點使用它 – seniorpreacher