0.1.1 • Published 9 years ago
expert-sender v0.1.1
node-expert-sender
Install
npm install expert-senderUsage
var ExpertSender = require('expert-sender');
var expertSender = new ExpertSender({
url: 'https://api.esv2.com/',
key: 'yourKey'
});
expertSender.addUserToList({
email: 'test@example.com',
listId: 1,
}).then(function (res) {
console.log('success');
}).catch(function (err){
console.log(err);
});Methods
addUserToList(options)
Add subscriber to list
Parameters
options may contain next properties:
email- subscriber's email (required)listId- id of list (required)id- user id (if you want to change subscriber's email)firstName- subscriber's first namelastName- subscriber's last namename- subscriber's full name (first name + last name)trackingCode- id of source (form, web-site, etc.)vendor- id/name of traffic typeip- subscriber's IPproperties- array of extra properties (see example below)
Example
expertSender.addUserToList({
email: 'test@example.com',
listId: 1,
name: 'User',
ip: '127.0.0.1',
properties: [
{ id: 1, value: 'qwerty' },
{ id: 100, value: 123 }
]
});getLists(options)
Parameters
options contains:
seedLists- boolean, iftrue- test subscriber lists will be returned, defaults to false
Example
expertSender.getLists({
seedLists: true
});getUser(options)
Receive short, long, fully information about user or event history
Parameters
options contains:
email- subscriber's email (required)options- one ofShort,Long,Full,EventHistory
Example
expertSender.getUser({
email: 'test@example.com',
options: 'Full'
});createNewsletter(options)
Send email to specified recipients
Parameters
options contains:
recipients- object with lists for sending mailings. Must contain at least one ofseedLists,subscriberListsorsubscriberSegments(required, see example below)content- object with next properties -fromName- string displaying infromemail field (required) -fromEmail- email displaying infromemail field (required) -subject- subject of email (required) -html- html body (requiredhtmlorplain) -plain- plain text body (requiredhtmlorplain) -replyToName- string displaying inreply-toemail field -replyToEmail- email displaying inreply-toemail field -header- header template id -footer- footer template id
Example
expertSender.createNewsletter({
recipients: {
seedLists: [39, 25],
subscriberLists: [2, 3, 5, 8]
},
content: {
fromName: 'Test',
fromEmail: 'test@example.com',
subject: 'Hello',
html: '<h1 style="color:#ff0000;">Hello world!</h1>'
}
});sendTransactional(options)
Send email to specified recipients
Parameters
options contains:
transactionId- integer, (required)receiver- object, must contain at least one ofidandemail. May containlistId. (required)returnGuid- boolean. Default value isfalse.snippets- array of{name: 'snippetName', value: 'snippetValue'}pairs.attachments- array of{fileName: 'name', mimeType: 'type', content: 'base64-encoded string'}tuples.
Example
expertSender.sendTransactional({
transactionId: 1,
receiver: {
email: 'test@example.com' // should be in one of your lists
},
snippets: [
{name: 'mySnippet', value: 42}
]
});Note
ExpertSender API documentation is here.