A wrapper around nodemailer for township transactional emails.
This module collection of helper functions for sending authentication/authorization emails.
mail.confirm({
to: 'test@example.com',
from: 'test@example.com',
url: 'https://example.com/url/for/confirming/email'
})
npm install --save township-email
var townshipEmail = require('township-email')
var mail = townshipEmail({
transport: `smtps://${process.env.GMAIL_USER}%40gmail.com:${process.env.GMAIL_PASS}@smtp.gmail.com`
})
mail.confirm({
to: 'sethvincent+emailtest@gmail.com',
from: 'sethvincent+emailtest@gmail.com',
url: 'https://example.com/url/for/confirming/email'
}, function (err) {
console.log(err)
})
You can use any nodemailer transport you like with this library. The above example shows basic SMTP usage.
Check out nodemailer for more information on transports
You can override any of the emails this module sends be using the emails
option in the constructor.
Each email is a function that takes an options object and returns a string.
var townshipEmail = require('township-email')
var mail = townshipEmail({
transport: `smtps://${process.env.GMAIL_USER}%40gmail.com:${process.env.GMAIL_PASS}@smtp.gmail.com`,
emails: {
confirm: confirm,
welcome: welcome
}
})
function confirm (options) {
return `<div>
<p>Hello!</p>
<p>Verify your email address by clicking this link:</p>
<p><b><a href="${options.url}">Confirm your account</a></b></p>
<p>Or by following this url:</p>
<p><a href="${options.url}">${options.url}</a></p>
</div>`
}
function welcome (options) {
return `<div>
<p>Welcome, and thank you for creating an account!</p>
<p>Please reply to this email if you have any questions.</p>
</div>`
}
Contributions are welcome! Please read the contributing guidelines first.
It's important that this project contributes to a friendly, safe, and welcoming environment for all, particularly for folks that are historically underrepresented in technology. Read this project's code of conduct
Read about the changes to this project in CHANGELOG.md. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.