Javascript 带有Parse.com云代码和SendGrid的电子邮件通知

Javascript 带有Parse.com云代码和SendGrid的电子邮件通知,javascript,email,parse-platform,sendgrid,parse-cloud-code,Javascript,Email,Parse Platform,Sendgrid,Parse Cloud Code,上下文: 我正在使用Parse.com作为我的web应用程序的后端。我想在新用户注册后给自己发送一封电子邮件(即,新记录保存到“用户”表中)。我正在使用SendGrid模块进行解析 问题: 电子邮件无法发送。我既没有收到成功的回复,也没有收到错误的回复。日志文件打印“步骤2”,但不打印“步骤3”(见下文) 此外,我不确定“mySendGridFunction”是否涉及任何内容,是否需要更改 代码: Parse.Cloud.afterSave(Parse.User,函数(请求){ //指示功能启动

上下文:

我正在使用Parse.com作为我的web应用程序的后端。我想在新用户注册后给自己发送一封电子邮件(即,新记录保存到“用户”表中)。我正在使用SendGrid模块进行解析

问题:

电子邮件无法发送。我既没有收到成功的回复,也没有收到错误的回复。日志文件打印“步骤2”,但不打印“步骤3”(见下文)

此外,我不确定“mySendGridFunction”是否涉及任何内容,是否需要更改

代码:

Parse.Cloud.afterSave(Parse.User,函数(请求){ //指示功能启动 console.log(“**********************************************”); console.log(“**新用户电子邮件通知***”); console.log(“**********************************************”)

}))


好了,一切正常对于那些有类似问题的人,我只是删除了下面一行(并修复了结束括号):

我认为,只有当您想调用使用SendGrid的函数时,才需要这样做

// For New Users Only
if(!(request.object.existed())){
    // New User Identified
    console.log("New user identified");

    // Initialize SendGrid Module
    var sendgrid = require("sendgrid");
    sendgrid.initialize("myUsername", "myPassword");
    console.log("Step 2");

    // Send Email
    Parse.Cloud.define("mySendGridFunction", function(request, response) {
        console.log("Step 3");
        sendgrid.sendEmail({
            to: "me@mydomain.com",
            from: "sendgrid@parse.com",
            //from: "sendgrid@cloudcode.com",
            subject: "Notification: New User",
            text: "A new user has just signed up."
        }, {
            success: function(httpResponse) {
                console.log("User Notification email being sent");
                console.log("HTTP Response: " + httpResponse);
                response.success("User Notification email successfully sent");
            },
            error: function(httpResponse) {
                console.log("There was an error sending the User Notification email");
                console.error("HTTP Response: " + httpResponse);
                response.error("There was an error sending the User Notification email");
            }
        });
    });
}
    Parse.Cloud.define("mySendGridFunction", function(request, response) {