我希望在网页上点击按钮时向用户发送邮件。有没有办法用jquery,Parse,mailgun来实现这个目的?从Parse控制台我可以使用curl调用Parse.Cloud函数。但是如何在$(“#myButton”)内的按钮上调用“sendMail”函数。单击()?
答案 0 :(得分:1)
我已经这样做了,我就是这样做的。
http://www.chilifunfactory.com/chili-blog/send-emails-with-parse-and-mailgun
您需要在Parse中编写一些云代码。
Parse.Cloud.define("sendMail", function(request, response) {
var mailgun = require('mailgun');
mailgun.initialize('your domain.mailgun.org', 'key-your-key');
mailgun.sendEmail({
to: request.params.toEmail,
from: request.params.fromEmail,
subject: request.params.subject,
text: request.params.comments
},
{
success: function(httpResponse) {
console.log(httpResponse);
response.success("Email sent!");
},
error: function(httpResponse) {
console.error(httpResponse);
response.error("Uh oh, something went wrong");
}
});
});
然后在您的javascript中,您只需拨打该方法并发送电子邮件
即可 Parse.Cloud.run('sendMail',
{
"toEmail": "customer service email address",
"fromEmail": "customer email address,
"subject": "Subject",
"comments": "Customer Comments"
},
{
success: function(result) {
alert(result);
},
error: function(error) {
alert(error.message);
}
}
);