Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

node.js - how to write a Cloud Function for send email using SendGrid

I am trying to send email using sendGrid (In my mobile application). So i wrote a cloud function and deployed it into firebase.(using this,Visit https://angularfirebase.com/lessons/angular4-transactional-email-with-cloud-functions-and-sendgrid/).

it was uploaded to firebase. But, when i try to send post request(Using postman{"to":"[email protected]","from":"[email protected]","subject":"test-email","content":"content"}), in firebase log shows some errors

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
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)' },
     headers: {} } 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...