简体   繁体   English

尝试使用sendgrid发送电子邮件时出错

[英]I am getting an error when attempting to use sendgrid to send email

I am receiving an error, which I believe is coming back from sendgrid. 我收到一个错误,我相信它是从sendgrid回来的。 However, I cannot find this error in Twilio/Sendgrid troubleshooting documentation. 但是,我在Twilio / Sendgrid故障排除文档中找不到此错误。 I've seen some references to it that indicate that this an issue with a version mismatch. 我已经看到一些引用它表明这是一个版本不匹配的问题。 Here's the thing, I know very little about this project. 这就是事情,我对这个项目知之甚少。 The dev left a while back. 开发者离开了一会儿。 I've been trying to help, and fairly successful. 我一直在努力帮助,并且相当成功。 However, this one has me stumped. 然而,这个让我难过。 The error doesn't refer to any line number, or module (that I can tell) 错误不是指任何行号或模块(我可以告诉)

this is from the Firebase console log for the cloud function that is attempted to send this email: 这是来自Firebase控制台日志的尝试发送此电子邮件的云功能:

{ 
 insertId: "000000-55176214-acd2-453d-8258-048000f1e9e3"   
   labels: {…}   
 logName: "projects/wsos-base/logs/cloudfunctions.googleapis.com%2Fcloud-functions"   
 receiveTimestamp: "2019-06-21T16:40:19.541487656Z"   
   resource: {…}   
 severity: "ERROR"   
 textPayload: "TypeError: Object.values is not a function"   
 timestamp: "2019-06-21T16:40:13.253Z"   
 trace: "projects/wsos-base/traces/bdb710bad4f92297c239de4409de2323"   
}

The console log messages BEFORE the sendgrid.send call are showing in the log. 在日志中显示sendgrid.send调用之前的控制台日志消息。 None of the log messages AFTER this call are showing. 此调用之后没有显示任何日志消息。 I've commented out the entire call, and no error shows in the log file. 我已经注释掉了整个调用,并且日志文件中没有显示错误。 I'm almost 100% certain this is occurring in the call. 我几乎100%肯定这是在通话中发生的。 BUT, from looking up sendgrid stuff, I should be expecting at least an error number in response.I confirmed that the 'catch' is working, by substituting a string error message. 但是,从查找sendgrid的东西,我应该至少期待响应中的错误号。我通过替换字符串错误消息确认'catch'正在工作。 I do see that error message in the log. 我确实在日志中看到了该错误消息。 When I put it back to original catch, I get the reported "TypeError...Object.values…" message. 当我把它放回原始catch时,我得到报告的“TypeError ... Object.values ...”消息。 No error message. 没有错误消息。 No line number. 没有行号。 No module. 没有模块。

return admin.auth().getUser(user)
                      .then(mentorObj => {
                        var mentorEmail = mentorObj.email;
                        var menteeObj = doc2.data();
                        console.log("Sending to Mentor: ", mentorEmail);
                        const confirmationMentor = {
                              to: mentorEmail,
                              from: *******,
                              template_id: ********,    
                              dynamicTemplateData: {
                                name: mentor.firstName,
                             menteeName: "MenteeNameHere"
                          },
                        };
                        console.log("Sent to Mentor: ", confirmationMentor);

                        return sendgrid.send(confirmationMentor)
                          .then(() => {
                            // console.log('Confirmation successfully sent to ' + mentorEmail);
                            console.log("sending to mentee");
...
})
                         .catch(error => console.error(error.toString()));

Simply replacing the above "error.toString()" with "SomeText" replaces the TypeError message in the console with "SomeText". 只需用“SomeText”替换上面的“error.toString()”就可以用“SomeText”替换控制台中的TypeError消息。 Also, "sending to mentee" is NOT in the console logs. 此外,“发送给受指导者”不在控制台日志中。 Additionally ".values" is NOT referenced anywhere in all of the source code. 此外,在所有源代码中的任何地方都不引用“.values”。

In the console logs, I see the JSON being passed: 在控制台日志中,我看到传递的JSON:

{ to: '*****',
  from: '*****',
  template_id: '******',
  dynamicTemplateData: { name: 'Rocky McChocolate', menteeName: 'MenteeNameHere' } }

I put this in an online JSON validator, and it is invalid. 我把它放在一个在线JSON验证器中,它是无效的。 However, I believe that is because of how it is displayed in the log, and not how the JSON actually looks. 但是,我认为这是因为它在日志中的显示方式,而不是JSON的实际外观。 Since this was working, and all I changed was the template id. 由于这是有效的,我改变的只是模板ID。 well, I think I've described this above (perhaps in the wrong place). 好吧,我想我已经在上面描述了这一点(也许是在错误的地方)。 Client has a firebase app, and it sends out emails. 客户端有一个firebase应用程序,它会发送电子邮件。 They wanted a different email. 他们想要一封不同的邮箱。 So, I created the email (in Twilio/Sendgrid), and changed the template_id value and expected new email to be sent. 因此,我创建了电子邮件(在Twilio / Sendgrid中),并更改了template_id值并发送了预期的新电子邮件。 Instead I get this error message. 相反,我收到此错误消息。 I've confirmed with the client that the emails were being sent prior to me working on it. 我已经向客户确认电子邮件是在我处理之前发送的。

That error, "TypeError: Object.values is not a function" is coming from your code, not from SendGrid. 该错误"TypeError: Object.values is not a function"来自您的代码,而不是来自SendGrid。 Somewhere, something is calling .values in an invalid way, but it's not in the code that you've shown here. 在某个地方,有些东西以无效的方式调用.values ,但它不在你在这里显示的代码中。

You're right that that is not valid JSON. 你是对的,那是无效的JSON。 Do you need to be calling a toJSON or similar on the values, to convert it to a JSON String? 你需要在值上调用toJSON或类似的东西,将它转换为JSON字符串吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在尝试使用Meteor搜索源包时出现错误? - Why am I getting an error when attempting to use the Meteor search-source package? 我不能使用sendgrid。 我无法发送 email - I cant use sendgrid . I cant send the email 在带有数组的对象上使用它时,为什么会出现$ parse错误? - Why I am getting $parse error when use it on object with array? 当我尝试在导航中使用道具时出现错误 - Getting Error when i am trying to use props in Navigation 尝试从 CSS 加载背景图像时出现 404 错误。 不确定如何进行 - I am getting a 404 error when attempting to load a background-image from CSS. Unsure how to proceed 当我尝试使用英特尔XDK发送Ajax查询时,为什么会出现错误? - Why am I getting an error when I try to send an Ajax query with the Intel XDK? 发送发布请求时出现复制键错误 - I am getting Duplication Key Error when I send a post request 发送没有主题的Sendgrid电子邮件 - Send Sendgrid Email Without Subject 使用 ipcRenderer 时出现错误(类型错误无法读取未定义的属性(读取“发送”)) - I am getting an error when using ipcRenderer (typeerror cannot read properties of undefined (reading 'send')) 不确定为什么在尝试将 Github Rep 发布到 Heroku 时出现错误 - Unsure why I am getting errors when attempting to publish Github Rep to Heroku
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM