我将云功能设置为向在数据库中创建用户的每个人发送电子邮件,但是即使进行很多检查和更改也无法正常工作
我的功能:
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))
});
问题:
{ 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 }