0
之前編碼和從未使用過的Cloud Code的新手。無法使用Parse Cloud Code和Mandrill發送電子郵件
我需要發送確認電子郵件,當有人用我的網頁上的表單提交他們的電子郵件與解析雲代碼,但我不能得到它的工作。我正在使用Mandrill雲模塊發送電子郵件。
我的問題是 -
a)我是否正確調用雲功能? b)變化的唯一變量是個人電子郵件地址。我是否正確傳遞該變量?
示例代碼真的有幫助。
感謝
這裏是我的雲代碼:
Parse.Cloud.define("introEmail", function(request, response) {
var Mandrill = require('mandrill');
Mandrill.initialize('*************');
mandrill.sendEmail({
message: {
text: "Hello!",
subject: "Thanks for Signing Up!",
from_email: "[email protected]",
from_name: "Chad",
to: [
{
email: request.params.Address,
name: ""
}
]
},
async: true
}, {
success: function(httpResponse) { response.success("Email sent!"); },
error: function(httpResponse) { response.error("Uh oh, something went wrong"); }
});
});
這裏是我的JS代碼:
$(".input-group-btn").click(function() {
console.log("Notify Me");
var Address = $(".form-control").val();
var Email = Parse.Object.extend("Email");
var email = new Email();
email.set("Address", Address);
console.log(Address);
email.save(null, {
success: function(email) {
console.log('New object created with objectId: ' + email.id);
Parse.Cloud.run(introEmail,Address)
},
error: function(email, error) {
alert('Could not accept email address: ' + error.message);
}
});
});