我正在尝试使用sendGrid发送电子邮件(在我的移动应用程序中)。所以我写了一个云函数并将其部署到firebase中。(使用它,访问https://angularfirebase.com/lessons/angular4-transactional-email-with-cloud-functions-and-sendgrid/)。
它被上传到firebase。但是,当我尝试发送post请求(使用postman{"to":"[email protected]","from":"[email protected]","subject":"test-email","content":"content"}
)时,在firebase日志中显示一些错误
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拥有的服务,因此您需要切换到“Flame”或“Blaze”计划。