1

datasource.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"
        }
      }]
}
       

model-config.json

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

mymodel.js (Extends default loopbacl's user model)

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;
      }

When I am creating new user, this afterRemote 'create' code is running but while sending mail it is giving following error:

{
  "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)"
  }
}

I have created a new domain in Bigrock and using the free email service provided by them. Please suggest what am I doing wrong here.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Have you seen my example at https://github.com/strongloop/loopback-faq-email? – superkhau Apr 19 '15 at 20:36
  • I have checked your example and it seems to be similar, the only difference is I am sending a mail whenever a new user is added. It seems there is some problem with my configuration in datasource.json. Is there any way to verify the email config settings I have given before running the code. Can you also please elaborate what should I actually provide in following fields: "auth": { "user": "name@myapp.in", "pass": "pwd" } Here user is the email id I use to login to the service provider or the email id I am using to send mails. – Anurag Dwivedi Apr 20 '15 at 16:58

0 Answers0