我正在尝试使用sendGrid发送电子邮件(在我的移动应用程序中)。因此,我编写了一个云函数并将其部署到firebase中。(使用此功能,访问https://angularfirebase.com/lessons/angular4-transactional- email-with-cloud-functions-and- sendgrid/)。
它已上传到Firebase。但是,当我尝试发送发帖请求(使用postman {"to":"user1@gmail.com","from":"duser253@gmail.com","subject":"test- email","content":"content"})时,firebase日志中显示了一些错误
{"to":"user1@gmail.com","from":"duser253@gmail.com","subject":"test- email","content":"content"}
SendGridError: Response error at /user_code/node_modules/sendgrid/lib/sendgrid.js:104:23 at ClientRequest.<anonymous> (/user_code/node_modules/sendgrid/node_modules/sendgrid-rest/lib/client.js:124:7) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at TLSSocket.socketErrorListener (_http_client.js:310:9) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at connectErrorNT (net.js:1040:8) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback (internal/process/next_tick.js:128:9) message: 'Response error', response: { statusCode: 500, body: { message: 'getaddrinfo ENOTFOUND api.sendgrid.com api.sendgrid.com:443', name: 'Error', stack: 'Error: getaddrinfo ENOTFOUND api.sendgrid.com api.sendgrid.com:443\n at errnoException (dns.js:28:10)\n at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)' }, headers: {} }
您需要采用“火焰”或“火焰”定价方案。
事实上,免费的“ Spark”计划“仅允许对Google拥有的服务的出站网络请求”。请参阅https://firebase.google.com/pricing/(将鼠标悬停在“云函数”标题后面的问号上)
由于Sendgrid不是Google拥有的服务,因此您需要切换到“火焰”或“大火”计划。