Skip to content

sailscastshq/sails-hook-mail

Repository files navigation

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 || '[email protected]',
    name: process.env.MAIL_FROM_NAME || 'The Boring JavaScript Stack'
  }
}

Supported transports

Email Partners

A big thank you to all our partners for their contributions and efforts in making Sails Mail development possible.

Become an Email Partner

Interested in becoming an Email Partner of Sails Mail? Email Kelvin at [email protected] with the subject "Become Sails Mail Partner".