SparkPost / node-sparkpost

SparkPost client library for Node.js
https://www.sparkpost.com/
Other
180 stars 42 forks source link

Sparkpost with Node.js transmission error #247

Open matthewshipman40 opened 4 years ago

matthewshipman40 commented 4 years ago

I'm having some trouble sending my first email via Sparkpost with node.JS. Any thoughts on trouble shooting would be greatly appreciated. The code below is part of a google cloud function that always returns the following error object:

{ Error: getaddrinfo EAI_AGAIN api.sparkpost.com:443 at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26) errno: 'EAI_AGAIN', code: 'EAI_AGAIN', syscall: 'getaddrinfo', hostname: 'api.sparkpost.com', host: 'api.sparkpost.com', port: '443' }

/////////// Code /////////////// const SparkPost = require('sparkpost') const client = new SparkPost('06b7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

exports.sendMail = functions.https.onCall((context) => { client.transmissions.send({ content: { from: 'dropaprop.com', // this is the actual verified domain. I also tried myname@dropaprop.com where "myname" is an established email address subject: 'Hello from node-sparkpost', html: '

Hello world

' }, recipients: [ {address: 'matthewshipman40@gmail.com'} ] }) .then(data => { console.log('Woohoo! You just sent your first mailing!') console.log(data) }) .catch(err => { console.log('Whoops! Something went wrong') console.log(err) }) })

/////////////// END CODE ///////////////