diet-mail
Send Emails with diet using NodeMailer and ECT.
Based on:
- Nodemailer for handling SMTP
- ECT for HTML templates.
Install
npm install diet-mail
Usage
Let's make a simple folder structure like this:
/yourApp indexjs /node_modules /mail testhtml
Setup the app in index.js
:
// Require Dietvar server = // Create Appvar app = // Configure Domainapp // Require Diet Mailvar Mailer = ; // Setup Mail Instanceappmail = host : 'smtp.mandrillapp.com' // smtp hostname port : 587 // port for secure smtp debug : true // display debug log from : 'MyCompany' auth : user: "you@example.com" // smtp username pass: "123123" // smtp password templates: apppath+'/mail/' // template directory
After you made Mail Instance you can send emails with it's return value app.mail
:
app
You can create html templates in the template directory. /yourApp/mail/test.html
could look like this:
Hello {{-this.customKey}}!This is a test mail!
Notice the {{-this.customKey}}
. Everything passed to app.mail
is accessible from the template.
Options for Mail Instance
app
- You can use any option that Nodemailer has by passing it as an object for the first argument.
- Optional Callback
Options for app.mail()
This is a shorthand for mail.sendMail
from nodemailer. Passing anything as an object for the first argument will change the defaults.
app
License
(The MIT License)
Copyright (c) 2014 Halász Ádám mail@adamhalasz.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.