user3155632 user3155632 - 4 months ago 49
Node.js Question

How do i setup SMTP with Loopback.io

How to setup SMTP server with loopback.io mbaas? i have gone through all the documentation but i couldn't find it.
How to give/define my smtp server settings in loopback config file if there is way to do so.

Answer

The STMP transport can be configured in the datasources.json, for example:

"mail": {
    "defaultForType": "mail",
    "connector": "mail",
    "transports": [ {
           type: 'SMTP',
           host: "smtp.gmail.com", // hostname
           secureConnection: true, // use SSL
           port: 465, // port for secure SMTP
           auth: {
               user: "gmail.user@gmail.com",
               pass: "userpass"
           }
       }
    ]
  },

Or:

app.models.email.setupTransport({
       type: 'SMTP',
       host: "smtp.gmail.com", // hostname
       secureConnection: true, // use SSL
       port: 465, // port for secure SMTP
       auth: {
           user: "gmail.user@gmail.com",
           pass: "userpass"
       }
   });