0.1.0 • Published 2 months ago

sails-hook-mail v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Mail

The simple elegant way to send emails from a Sails application

Getting Started

npm i sails-hook-mail --save

Usage

In your Sails action you can use the send helper like so:

await sails.helpers.mail.send.with({
  subject: 'Verify your email',
  template: 'email-verify-account',
  to: user.email,
  templateData: {
    token: user.emailProofToken,
    fullName: user.fullName
  }
})

Mailers

Mail supports a couple of mailers including:

  • log
  • SMTP

To use Mail, create a config/mail.js and specify your default mailer as well as the mailers you'd like to support in your Sails application like so:

module.exports.mail = {
  default: process.env.MAIL_MAILER || 'log',
  mailers: {
    smtp: {
      transport: 'smtp'
    },
    log: {
      transport: 'log'
    }
  },
  from: {
    address: process.env.MAIL_FROM_ADDRESS || 'boring@sailscasts.com',
    name: process.env.MAIL_FROM_NAME || 'The Boring JavaScript Stack'
  }
}

log

To use the log mailer, set the default property of config/mail.js to log and make sure you have a log mailer under the mailers object.

Sails will log your email to the console

SMTP

To use SMTP as a mailer set it as the default in config/mail.js and also install the peer dependency nodemailer:

npm i nodemailer --save

Then in your config/local.js you can provide the SMTP credentials like so:

// config/local.js
smtp: {
  host: 'HOST',
  username: 'USERNAME',
  password: 'PASSWORD'
}
0.1.0

2 months ago

0.0.9

2 months ago

0.0.8

3 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago

1.0.0

10 months ago