1

数据源.json:

"emailDs": {
  "name": "emailDs",
    "connector": "mail",
      "transports": [{
        "type": "smtp",
        "host": "smtp.myapp.in",
        "secure": true,
        "secureConnection": true,
        "port": 587,
        "tls": {
          "rejectUnauthorized": false
        },
        "auth": {
          "user": "name@myapp.in",
          "pass": "pwd"
        }
      }]
}
       

模型配置.json

"Email": {
            "dataSource": "emailDs"
      }

mymodel.js(扩展默认 loopbacl 的用户模型)

var options = {
      type: 'email',
      to: myUser.email,
      from: 'name@myapp.in',
      subject: 'Thanks for registering.',
      template: path.resolve(__dirname, '../../server/views/verify.ejs'),
      redirect: '/verified',
      entrepreneur: entrepreneur
    };

    myUser.verify(options, function(err, response) {
      if (err) {
        next(err);
        return;
      }

当我创建新用户时,这个afterRemote 'create' 代码正在运行,但是在发送邮件时它给出了以下错误:

{
  "error": {
    "name": "Error",
    "status": 500,
    "message": "getaddrinfo EAI_AGAIN",
    "code": "EAI_AGAIN",
    "errno": "EAI_AGAIN",
    "syscall": "getaddrinfo",
    "hostname": "smtp.myapp.in",
    "stack": "Error: getaddrinfo EAI_AGAIN\n    at Object.exports._errnoException (util.js:746:11)\n    at errnoException (dns.js:49:15)\n    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)"
  }
}

我在 Bigrock 中创建了一个新域,并使用他们提供的免费电子邮件服务。请建议我在这里做错了什么。

4

0 回答 0