我有以下函数,当我的数据库中的(请求的服务状态)值发生变化时触发:
exports.cheackUserService = functions.database.ref('Users/{userID}/requested service status').onWrite((event) => {
var requestedServiceStatus = event.data.val();
var userId = event.params.userID;
var mailgun = require("mailgun-js");
var api_key = 'key-XXXXXXXXXXXXXX';
var DOMAIN = 'sandbox76c6f74ddab14862816390c16f37a272.mailgun.org';
var mailgun = require('mailgun-js')({apiKey: api_key, domain: DOMAIN});
var data = {
from: 'Excited User <postmaster@sandbox76c6f74ddab14862816390c16f37a272.mailgun.org>',
to: 'rayteamstudio@gmail.com',
subject: 'Complex',
text: 'Testing some Mailgun awesomness!',
};
console.log('data: ',data);
mailgun.messages().send(data, function (error, body) {
console.log('error: ',error);
});
});
该函数执行得很好但电子邮件永远不会发送。相反,它会记录此错误:
error: { Error: getaddrinfo ENOTFOUND api.mailgun.net api.mailgun.net:443
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'api.mailgun.net',
host: 'api.mailgun.net',
port: 443 }
有人可以帮忙吗?
注意:电子邮件(rayteamstudio@gmail.com)是我用来创建mailgun帐户的电子邮件。