1
背景:与Parse.com云代码和SendGrid电子邮件通知
我使用Parse.com作为后端为我的Web应用程序。我想在新用户注册时向我自己发送一封电子邮件(即将新记录保存到“用户”表中)。我正在使用SendGrid模块进行分析。
问题:
的电子邮件不发送。我既没有收到成功也没有收到错误回应。日志文件打印“步骤2”,但不打印“步骤3”(见下文)。
此外,我不确定是否“mySendGridFunction”指的是任何东西,需要更改。
CODE:
Parse.Cloud.afterSave(Parse.User,函数(请求){// 指示功能启动 的console.log(“********* *************************“); console.log(”**新用户电子邮件通知***“); console.log (“***********************************”);
// 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: "[email protected]", from: "[email protected]", //from: "[email protected]", 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"); } }); }); }
});