1
votes

I see that loopback comes with nodemailer integrated as a node module. I tried to follow the docs to send a hello world mail via the angular-sdk

http://apidocs.strongloop.com/loopback/#emailsendoptions-callback

However, the docs are not really specific here. I tried the following:

    User.email
      from: "[email protected]"
      to: "[email protected]"
      subject: "hello world"
      html: "<b> Hello Wolrd </b>"

which gives me this error, even though I have an authenticated user instance.

POST http://localhost:3000/api/users/Emails 401 (Unauthorized) angular.js:8407

intercepted rejection of  /api/users/Emails 401 

My question is how can I configure the email module as to set up SMTP etc. Any help would be much appreciated.

Thanks Sven

2
hey do you find any solution? - user5570620

2 Answers

3
votes

This thread is quite old, but this is how you implement the loopback email feature:

MyModel.app.models.Email.send({
        to: To,
        from: From,
        subject: Subject,
        text: Text,
        html: Html
      }, function(err, mail) {
        console.log('Email Sent!');
        console.log(mail);
        cb(err);
      });
0
votes

I don't think we have any docs specifically on using Mail with the Angular SDK, but see http://docs.strongloop.com/display/LB/Using+built-in+models#Usingbuilt-inmodels-Emailmodel for info on just sending an email message in LoopBack. A good approach might be to get it working on the backend first and then try doing it via Angular.

Rand