How do i setup SMTP with Loopback.io

2019-04-02 09:55发布

问题:

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.

回答1:

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