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"); } }); }); }
});