Skip to content

Commit

Permalink
[docs] Updated ReadMe with template examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed May 18, 2011
1 parent fb8c11e commit 54a3409
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Readme.md
Expand Up @@ -47,6 +47,58 @@ node_mailer SSL connections (not TLS / STARTTLS, just SSL from the beginning of
add an option ssl: true. See usage above.


# USING TEMPLATES

### create a simple template

/templates/sample.txt

Hello {{username}},

This is a sample template of the node mailer.

It uses mustache templating to do basic search and replaces.

The {{color}} {{animal}} {{adverb}} ran over the {{noun}}.

### then send the mail using some simple JSON based Mustache replacement.

var email = require("../lib/node_mailer");

for(var i = 0; i < 10; i++){

email.send({
host : "localhost", // smtp server hostname
port : "25", // smtp server port
domain : "localhost", // domain used by client to identify itself to server
to : "marak.squires@gmail.com",
from : "obama@whitehouse.gov",
subject : "node_mailer test email",
template : "../templates/sample.txt", // path to template name
data : {
"username": "Billy Bob",
"color": function(){
var arr = ["purple", "red", "green", "yello"];
return arr[Math.floor(Math.random()*3)];
},
"animal": "monkey",
"adverb": "quickly",
"noun": "hot lava"
},

authentication : "login", // auth login is supported; anything else is no auth
username : "dXNlcm5hbWU=", // Base64 encoded username
password : "cGFzc3dvcmQ=" // Base64 encoded password
},
function(err, result){
if(err){ console.log(err); }
});
}





## Authors

Marak Squires, Elijah Insua, Fedor Indutny, Bradley Meck
Expand Down

0 comments on commit 54a3409

Please sign in to comment.