1

i set my cloud functions to send an email to everyone who create a user in my DB, but even tho a lot of checking and changes things wouldn't work

my function:

exports.ConfirmationEmaill = functions.firestore
        .document('user/{userId}')
        .onCreate(event => {
            const userId = event.params.userId;

            const db = admin.firestore()

            return db.collection('user').doc(userId)
                    .get()
                    .then(doc => {
                        const user = doc.data()

                        const msg = {
                            to: user.email,
                            from: 'email@gmail.com',
                            subject: 'Confirmation d e-mail',
                            templateId: templateId,
                            substitutionWrappers: ['{{', '}}'],
                            substitutions:{
                                email: user.email
                            }
                        };

                        return sgMail.send(msg)
                    })
                    .then(() => console.log('email sent!'))
                    .catch( err => console.log(err))
        });

problem:

    { Error: getaddrinfo EAI_AGAIN api.sendgrid.com:443
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
  errno: 'EAI_AGAIN',
  code: 'EAI_AGAIN',
  syscall: 'getaddrinfo',
  hostname: 'api.sendgrid.com',
  host: 'api.sendgrid.com',
  port: 443 }
Renaud Tarnec
  • 53,666
  • 7
  • 52
  • 80
Achraf
  • 21
  • 3

0 Answers0