mirror of https://github.com/eleith/emailjs.git
Update Readme.md
This commit is contained in:
parent
6efb0ffa41
commit
6a9cd97e38
88
Readme.md
88
Readme.md
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue