trailpack-email
v3.0.1
Published
Add a Trails service to sending emails
Downloads
7
Maintainers
Readme
trailpack-email
: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: '[email protected]',
pass: 'pass'
}
},
/*
* Default data use with EmailService.send
* from, to, css, bcc, subject, text, html, attachments
*/
defaultData: {
from: '[email protected]'
}
}
Usage
Now you can send emails like this :
this.app.services.EmailService.send({
to: '[email protected]',
subject: 'Test',
text: 'test',
html: '<p>test</p>'
}, (err, info) => {
})
//Or with Promise
this.app.services.EmailService.send({
to: '[email protected]',
subject: 'Test',
text: 'test',
html: '<p>test</p>'
}).then(info => {
}).catch(err => this.log.error(err))
License
Support on Beerpay
Hey dude! Help me out for a couple of :beers:!