https://github.com/sailscastshq/sails-hook-mail
The simple elegant way to send emails from a Sails application
https://github.com/sailscastshq/sails-hook-mail
nodemailer resend resend-email sails-hook sailsjs smtp transactional-emails
Last synced: 2 months ago
JSON representation
The simple elegant way to send emails from a Sails application
- Host: GitHub
- URL: https://github.com/sailscastshq/sails-hook-mail
- Owner: sailscastshq
- License: mit
- Created: 2023-07-27T14:14:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2026-03-31T17:04:05.000Z (2 months ago)
- Last Synced: 2026-03-31T19:13:57.173Z (2 months ago)
- Topics: nodemailer, resend, resend-email, sails-hook, sailsjs, smtp, transactional-emails
- Language: JavaScript
- Homepage: https://docs.sailscasts.com/mail
- Size: 98.6 KB
- Stars: 9
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mail
The simple elegant way to send emails from a Sails application
## Getting Started
```sh
npm i sails-hook-mail --save
```
## Usage
In your Sails action you can use the `send` helper like so:
```js
await sails.helpers.mail.send.with({
subject: 'Verify your email',
template: 'verify-account',
to: user.email,
templateData: {
token: user.emailProofToken,
fullName: user.fullName
}
})
```
Template names are relative to `views/emails/`, so `template: 'verify-account'`
maps to `views/emails/verify-account.ejs`. Existing templates and callers that
still use names like `email-verify-account` continue to work too.
## 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:
```js
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'
}
}
```
## Supported transports
- [Log](https://docs.sailscasts.com/mail/local-development#log-transport)
- [SMTP](https://docs.sailscasts.com/mail/smtp-transport)
- [Mailtrap](https://docs.sailscasts.com/mail/mailtrap-transport)
- [Resend](https://docs.sailscasts.com/mail/resend-transport)
## 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 [koo@hey.com](mailto:koo@hey.com?subject=Become%20Sails%20Mail%20Partner) with the subject "Become Sails Mail Partner".