3.0.1 • Published 6 years ago

trailpack-email v3.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

trailpack-email

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

:package: 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 :beers:!

Beerpay Beerpay

3.0.1

6 years ago

3.0.0

6 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago