node-expert-sender
Install
npm install expert-sender
Usage
var ExpertSender = require('expert-sender');
var expertSender = new ExpertSender({
url: 'https://api.esv2.com/',
key: 'yourKey'
});
expertSender.addUserToList({
email: '[email protected]',
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: '[email protected]',
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: '[email protected]',
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
,subscriberLists
orsubscriberSegments
(required, see example below)content
- object with next propertiesfromName
- string displaying infrom
email field (required)fromEmail
- email displaying infrom
email field (required)subject
- subject of email (required)html
- html body (requiredhtml
orplain
)plain
- plain text body (requiredhtml
orplain
)replyToName
- string displaying inreply-to
email fieldreplyToEmail
- email displaying inreply-to
email fieldheader
- header template idfooter
- footer template id
Example
expertSender.createNewsletter({
recipients: {
seedLists: [39, 25],
subscriberLists: [2, 3, 5, 8]
},
content: {
fromName: 'Test',
fromEmail: '[email protected]',
subject: 'Hello',
html: '<h1 style="color:#ff0000;">Hello world!</h1>'
}
});
Note
ExpertSender API documentation is here.