npm install expert-sender
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);
});
Add subscriber to list
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)
expertSender.addUserToList({
email: 'test@example.com',
listId: 1,
name: 'User',
ip: '127.0.0.1',
properties: [
{ id: 1, value: 'qwerty' },
{ id: 100, value: 123 }
]
});
options
contains:
seedLists
- boolean, iftrue
- test subscriber lists will be returned, defaults to false
expertSender.getLists({
seedLists: true
});
Receive short, long, fully information about user or event history
options
contains:
email
- subscriber's email (required)options
- one ofShort
,Long
,Full
,EventHistory
expertSender.getUser({
email: 'test@example.com',
options: 'Full'
});
Send email to specified recipients
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
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>'
}
});
Send email to specified recipients
options
contains:
transactionId
- integer, (required)receiver
- object, must contain at least one ofid
andemail
. 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.
expertSender.sendTransactional({
transactionId: 1,
receiver: {
email: 'test@example.com' // should be in one of your lists
},
snippets: [
{name: 'mySnippet', value: 42}
]
});
ExpertSender API documentation is here.