2

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":"user1@gmail.com","from":"duser253@gmail.com","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\n    at errnoException (dns.js:28:10)\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)' },
     headers: {} } 
Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121
Dulaj Madusanka
  • 308
  • 2
  • 17
  • 2
    On which payment plan are you? The free "Spark" plan allows outbound network requests only to Google-owned services. You need to be on the "Flame" or "Blaze" plan, since Sendgrid is not a Google-owned service. See https://firebase.google.com/pricing/ – Renaud Tarnec Oct 22 '18 at 13:19
  • I changed the payment plan. Now it shows another error. (SendGridError: Response error at /user_code/node_modules/sendgrid/lib/sendgrid.js:104:23 at IncomingMessage. (/user_code/node_modules/sendgrid/node_modules/sendgrid-rest/lib/client.js:112:9) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickDomainCallback) – Dulaj Madusanka Oct 23 '18 at 04:21
  • It's working @RenaudTarnec.Thanks a lot – Dulaj Madusanka Oct 23 '18 at 05:50
  • Good! I will therefore add an answer based on my comment. You may accept it. – Renaud Tarnec Oct 23 '18 at 06:03
  • Thanx bro. it is really helped to me. – Dulaj Madusanka Oct 23 '18 at 09:49

1 Answers1

6

You need to be on the "Flame" or "Blaze" pricing plan.

As a matter of fact, the free "Spark" plan "allows outbound network requests only to Google-owned services". See https://firebase.google.com/pricing/ (hover your mouse on the question mark situated after the "Cloud Functions" title)

Since Sendgrid is not a Google-owned service, you need to switch to the "Flame" or "Blaze" plan.

Renaud Tarnec
  • 79,263
  • 10
  • 95
  • 121