Wondering what’s next for npm?Check out our public roadmap! »

trailpack-email

3.0.1 • Public • Published

trailpack-email

Gitter NPM version NPM downloads Build status Dependency Status Code Climate Beerpay Beerpay

📦 Add a Trails service to sending emails

Intallation

With yo :

npm install -g yo generator-trails
yo trails:trailpack trailpack-email

With npm (you will have to create config file manually) :

npm install --save trailpack-email

Configuration

First you need to add this trailpack to your main configuration :

// config/main.js
 
module.exports = {
   ...
 
   packs: [
      ...
      require('trailpack-email'),
      ...
   ]
   ...
}

Then:

// config/email.js
module.exports = {
  //Custom transporter object to send email, by default created from smtp values but can be override here
  customTransporter: null,
  
    /*
     * SMTP Configuration
     * @see {@link http://nodemailer.com/2-0-0-beta/setup-smtp/}
     */
    smtp: {
      host: 'smtp.gmail.com',
      port: 465,
      secure: true, // use SSL
      auth: {
        user: 'user@gmail.com',
        pass: 'pass'
      }
    },
    /*
     * Default data use with EmailService.send
     * from, to, css, bcc, subject, text, html, attachments
     */
    defaultData: {
      from: 'noreply@gmail.com'
    }
}

Usage

Now you can send emails like this :

this.app.services.EmailService.send({
      to: 'user@gmail.com',
      subject: 'Test',
      text: 'test',
      html: '<p>test</p>'
    }, (err, info) => {

    })
//Or with Promise
this.app.services.EmailService.send({
      to: 'user@gmail.com',
      subject: 'Test',
      text: 'test',
      html: '<p>test</p>'
    }).then(info => {

    }).catch(err => this.log.error(err))
    

License

MIT

Support on Beerpay

Hey dude! Help me out for a couple of 🍻!

Beerpay Beerpay

Install

npm i trailpack-email

DownloadsWeekly Downloads

25

Version

3.0.1

License

MIT

Unpacked Size

8.75 kB

Total Files

10

Last publish

Collaborators

  • avatar