Update Readme.md

This commit is contained in:
eleith 2011-12-09 03:20:54 -08:00
parent 6efb0ffa41
commit 6a9cd97e38
1 changed files with 46 additions and 42 deletions

View File

@ -21,59 +21,63 @@ send emails, html and attachments (files, streams and strings) from node.js to a
# EXAMPLE USAGE - text only emails
var email = require("./path/to/emailjs/email");
var server = email.server.connect({
user: "username",
password:"password",
host: "smtp.gmail.com",
ssl: true
});
```javascript
var email = require("./path/to/emailjs/email");
var server = email.server.connect({
user: "username",
password:"password",
host: "smtp.gmail.com",
ssl: true
});
// send the message and get a callback with an error or details of the message that was sent
server.send({
text: "i hope this works",
from: "you <username@gmail.com>",
to: "someone <someone@gmail.com>, another <another@gmail.com>",
cc: "else <else@gmail.com>",
subject: "testing emailjs"
}, function(err, message) { console.log(err || message); });
// send the message and get a callback with an error or details of the message that was sent
server.send({
text: "i hope this works",
from: "you <username@gmail.com>",
to: "someone <someone@gmail.com>, another <another@gmail.com>",
cc: "else <else@gmail.com>",
subject: "testing emailjs"
}, function(err, message) { console.log(err || message); });
```
# EXAMPLE USAGE - html emails and attachments
var email = require("./path/to/emailjs/email");
var server = email.server.connect({
user: "username",
password:"password",
host: "smtp.gmail.com",
ssl: true
});
```javascript
var email = require("./path/to/emailjs/email");
var server = email.server.connect({
user: "username",
password:"password",
host: "smtp.gmail.com",
ssl: true
});
var headers = {
text: "i hope this works",
from: "you <username@gmail.com>",
to: "someone <someone@gmail.com>, another <another@gmail.com>",
cc: "else <else@gmail.com>",
subject: "testing emailjs"
};
var headers = {
text: "i hope this works",
from: "you <username@gmail.com>",
to: "someone <someone@gmail.com>, another <another@gmail.com>",
cc: "else <else@gmail.com>",
subject: "testing emailjs"
};
// create the message
var message = email.message.create(headers);
// create the message
var message = email.message.create(headers);
// attach an alternative html email for those with advanced email clients
message.attach({data:"<html>i <i>hope</i> this works!</html>", alternative:true});
// attach an alternative html email for those with advanced email clients
message.attach({data:"<html>i <i>hope</i> this works!</html>", alternative:true});
// attach attachments because you can!
message.attach({path:"path/to/file.zip", type:"application/zip", name:"renamed.zip"});
// attach attachments because you can!
message.attach({path:"path/to/file.zip", type:"application/zip", name:"renamed.zip"});
// send the message and get a callback with an error or details of the message that was sent
server.send(message, function(err, message) { console.log(err || message); });
// send the message and get a callback with an error or details of the message that was sent
server.send(message, function(err, message) { console.log(err || message); });
// you can continue to send more messages with successive calls to 'server.send',
// they will be queued on the same smtp connection
// or you can create a new server connection with 'email.server.connect'
// to asynchronously send individual emails instead of a queue
// you can continue to send more messages with successive calls to 'server.send',
// they will be queued on the same smtp connection
// or you can create a new server connection with 'email.server.connect'
// to asynchronously send individual emails instead of a queue
```
# API
## email.server.connect(options)