Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
typerandom committed Apr 16, 2013
1 parent 9cf2276 commit 6810bef
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ AlphaMail supports templating (Comlang), DKIM-signatures and reliable delivery.

http://amail.io/

### How to start?

1) Install with NPM:

Expand All @@ -21,11 +22,25 @@ http://amail.io/
var alphamail = require('alphamail');
var emailService = new alphamail.EmailService("API-TOKEN");

var data = {name:"Joe", pwns:true, likesCats:"certainly"};
var data = {
id: "abc-123-456",
name: "Some Guy",
profile_url: "http://domain.com/profile/ABC-123-456/",
recommended_profiles: [
{
id: "abc-222-333",
name: "Jane Joe",
profile_url: "http://domain.com/profile/ABC-222-333/",
profile_image_url: "http://img.domain.com/profile/abc-222-333.jpg",
age: 24
}
]
};

var payload = new alphamail.EmailMessagePayload()
.setProjectId(1235) // ID of your AlphaMail project
.setSender(new alphamail.EmailContact("My Company", "your@domain.com"))
.setReceiver(new alphamail.EmailContact("Some dude", "receiver@some55-domain.com"))
.setReceiver(new alphamail.EmailContact("Some guy", "some@guy.com"))
.setBodyObject(data);

emailService.queue(payload, function(error, result){
Expand All @@ -34,4 +49,38 @@ http://amail.io/
return;
}
console.log("Email sent! ID = " + result);
});
});

### Usage

Include the module

var alphamail = require('alphamail');

Initialize an email service with your token

<sub><i>Don't have a token? Head to http://amail.io/ and signup for a free AlphaMail account.</i></sub>

var emailService = new alphamail.EmailService(apiToken);

Queue an email for sending

emailService.queue(payload, callback);

<sub><i>Where payload is:</i></sub>

var payload = new alphamail.EmailMessagePayload()
.setProjectId(12345) // ID of your AlphaMail project
.setSender(new alphamail.EmailContact("My Company", "your@domain.com"))
.setReceiver(new alphamail.EmailContact("Some guy", "some@guy.com"))
.setBodyObject({/*Data to use in email*/});
<sub><i>Where callback is:</i></sub>

var callback = function(error, result){
if(error){
console.log(error);
}else{
console.log("Mail successfully sent! ID = " + result);
}
};

0 comments on commit 6810bef

Please sign in to comment.