Description
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 [email protected] where "myname" is an established email address
subject: 'Hello from node-sparkpost',
html: '
Hello world
'},
recipients: [
{address: '[email protected]'}
]
})
.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 ///////////////