1

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: "info@test.com"
      to: "sven@gmail.com"
      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

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
enigma
  • 79
  • 2
  • 11

2 Answers2

3

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);
      });
sidewaiise
  • 1,445
  • 3
  • 16
  • 27
0

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

RandM
  • 231
  • 1
  • 3