All Projects → mailersend → mailersend-nodejs

mailersend / mailersend-nodejs

Licence: MIT license
The official MailerSend Node.js SDK

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to mailersend-nodejs

mailersend-php
The official MailerSend PHP SDK
Stars: ✭ 23 (-43.9%)
Mutual labels:  transactional-emails, mailersend
mailersend-laravel-driver
The official MailerSend Laravel Driver
Stars: ✭ 14 (-65.85%)
Mutual labels:  transactional-emails, mailersend
Magento2 Gmail Smtp App
Configure Magento 2 to send email using Google App, Gmail, Amazon Simple Email Service (SES), Microsoft Office365 and many other SMTP (Simple Mail Transfer Protocol) servers
Stars: ✭ 281 (+585.37%)
Mutual labels:  transactional-emails
Laravel Postmark
A Postmark adapter for Laravel
Stars: ✭ 143 (+248.78%)
Mutual labels:  transactional-emails
Mailjet Apiv3 Java
[API v3] Mailjet Java API Wrapper
Stars: ✭ 53 (+29.27%)
Mutual labels:  transactional-emails
Sendgrid Java
The Official Twilio SendGrid Led, Community Driven Java API Library
Stars: ✭ 380 (+826.83%)
Mutual labels:  transactional-emails
Sendgrid Php
The Official Twilio SendGrid Led, Community Driven PHP API Library
Stars: ✭ 1,257 (+2965.85%)
Mutual labels:  transactional-emails
starter-postmark
A Maizzle starter based on Postmark's transactional email templates.
Stars: ✭ 39 (-4.88%)
Mutual labels:  transactional-emails
ohmysmtp-rails
A plugin for ActionMailer to send emails via MailPace.com
Stars: ✭ 31 (-24.39%)
Mutual labels:  transactional-emails
Cuttlefish
Transactional email server with a lovely web interface
Stars: ✭ 985 (+2302.44%)
Mutual labels:  transactional-emails
Mailjet Apiv3 Nodejs
[API v3] Official Mailjet API v3 NodeJS wrapper
Stars: ✭ 137 (+234.15%)
Mutual labels:  transactional-emails
Sendgrid Csharp
The Official Twilio SendGrid Led, Community Driven C#, .NetStandard, .NetCore API Library
Stars: ✭ 835 (+1936.59%)
Mutual labels:  transactional-emails
Phplist3
Fully functional Open Source email marketing manager for creating, sending, integrating, and analysing email campaigns and newsletters.
Stars: ✭ 393 (+858.54%)
Mutual labels:  transactional-emails
Suet
An analytics dashboard and reporting tool for Mailgun and Amazon SES transactional emails.
Stars: ✭ 114 (+178.05%)
Mutual labels:  transactional-emails
Grunt Email Workflow
A Grunt workflow for designing and testing responsive HTML email templates with SCSS.
Stars: ✭ 3,010 (+7241.46%)
Mutual labels:  transactional-emails
Mailjet Apiv3 Php
[API v3] Mailjet PHP Wrapper
Stars: ✭ 194 (+373.17%)
Mutual labels:  transactional-emails
Sendgrid Go
The Official Twilio SendGrid Led, Community Driven Golang API Library
Stars: ✭ 710 (+1631.71%)
Mutual labels:  transactional-emails
Sendgrid Python
The Official Twilio SendGrid Led, Community Driven Python API Library
Stars: ✭ 1,125 (+2643.9%)
Mutual labels:  transactional-emails
dotmailer-magento-extension
The official Engagement Cloud for Magento extension
Stars: ✭ 14 (-65.85%)
Mutual labels:  transactional-emails
Sendgrid Nodejs
The Official Twilio SendGrid Led, Community Driven Node.js API Library
Stars: ✭ 2,543 (+6102.44%)
Mutual labels:  transactional-emails

MailerSend Node.js SDK

MIT licensed

Table of Contents

Installation

Setup

npm install mailersend

Usage

Email

Send an email

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setReplyTo("[email protected]")
      .setReplyToName("Reply to name")
      .setSubject("Subject")
      .setHtml("This is the HTML content")
      .setText("This is the text content");

mailersend.send(emailParams);

Add CC, BCC recipients

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];
const cc = [
  new Recipient("[email protected]", "Your CC Client")
];
const bcc = [
  new Recipient("[email protected]", "Your BCC Client")
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setCc(cc)
      .setBcc(bcc)
      .setSubject("Subject")
      .setHtml("This is the HTML content")
      .setText("This is the text content");

mailersend.send(emailParams);

Send a template-based email

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setTemplateId('templateId')
      .setSubject("Subject")

mailersend.send(emailParams);

Advanced personalization

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const personalization = [
  {
    email: "[email protected]",
    data: {
      test: 'Test Value'
    },
  }
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setPersonalization(personalization)
      .setSubject("Subject, {{ test }}")
      .setHtml("This is the HTML content, {{ test }}")
      .setText("This is the text content, {{ test }}");

mailersend.send(emailParams);

Simple personalization

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const variables = [
  {
    email: "[email protected]",
    substitutions: [
      {
        var: 'test',
        value: 'Test Value'
      }
    ],
  }
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setVariables(variables)
      .setSubject("Subject, {$test}")
      .setHtml("This is the HTML content, {$test}")
      .setText("This is the text content, {$test}");

mailersend.send(emailParams);

Send email with attachment

const fs = require('fs');

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const Attachment = require("mailersend").Attachment;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const attachments = [
  new Attachment(fs.readFileSync('/path/to/file.pdf', {encoding: 'base64'}), 'file.pdf', 'attachment')
]

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setAttachments(attachments)
      .setSubject("Subject")
      .setHtml("This is the HTML content")
      .setText("This is the text content");

mailersend.send(emailParams);

Send a scheduled email

const fs = require('fs');

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const emailParams = new EmailParams()
      .setFrom("[email protected]")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setAttachments(attachments)
      .setSubject("Subject")
      .setSendAt(2443651141) //set sentAt is a timestamp - min: now, max: now + 72hours
      .setHtml("This is the HTML content")
      .setText("This is the text content");

mailersend.send(emailParams);

Send bulk emails

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const BulkEmails = require("mailersend").BulkEmails;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

const bulkEmails = new BulkEmails();

const recipients = [
  new Recipient("[email protected]", "Your Client")
];

const emailParams = new EmailParams()
  .setFrom("[email protected]")
  .setFromName("Your Name")
  .setRecipients(recipients)
  .setSubject("Subject")
  .setHtml("This is the HTML content")
  .setText("This is the text content");


bulkEmails.addEmail(emailParams)
bulkEmails.addEmails([
  emailParams,
  emailParams
])

mailersend.sendBulk(bulkEmails)
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

Get bulk request status

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getBulkEmailRequestStatus({
  bulk_email_id: 'xxx'
})
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

Tokens

Create a token

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.createToken({
  name: "Token name",
  domain_id: "xxx",
  scopes: [
    "email_full",
    "domains_read",
    "domains_full",
    "activity_read",
    "activity_full",
    "analytics_read",
    "analytics_full",
    "tokens_full",
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update token

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.updateToken({
  token_id: "xxx",
  status: "pause"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete token

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteToken({
  token_id: "xxx"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Activity

Get activity list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityList({
  domain_id: "xxx",
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Analytics

Get activity data by date

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityByDate({
  date_from: 1443651141,
  date_to: 2443651141,
  event: ["processed"]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Opens by country

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityByCountry({
  date_from: 1443651141,
  date_to: 2443651141
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Opens by user-agent

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityByUserAgent({
  date_from: 1443651141,
  date_to: 2443651141
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Opens by reading environment

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.activityByReadingEnvironment({
  date_from: 1443651141,
  date_to: 2443651141
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Domains

Get a list of domains

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainList({
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get domain

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domain({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete domain

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteDomain({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get a list of recipients per domain

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainRecipients({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update domain settings

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.domainSettings({
  domain_id: 'xxx',
  send_paused: false
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Add a domain

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addDomain({
    name: "example.com",
    return_path_subdomain: "rp_subdomain",
    custom_tracking_subdomain: "ct_subdomain",
    inbound_routing_subdomain: "ir_subdomain",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

Get DNS records

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getDNS({
    domain_id: "xxx",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

Get verification status

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.verifyDomain({
    domain_id: "xxx",
  })
  .then((response) => response.json())
  .then((data) => {
    console.log(data);
  });

Inbound

Get inbound list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.inboundList()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.inbound({
  inbound_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Create inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.createInbound({
  domain_id: "xxx",
  name: "Test name",
  domain_enabled: true,
  inbound_domain: "test.yourdomain.com",
  inbound_address: "[email protected]",
  inbound_subdomain: "inbound",
  match_filter: {
    type: "match_all"
  },
  catch_filter: {
    type: "catch_recipient",
    filters: [
      {
        comparer: "equal",
        value: "test"
        }
    ]
  },
  forwards: [
    {
      type: "webhook",
      value: "https://www.yourdomain.com/hook"
    }
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.updateInbound({
  inbound_id: "xxx",
  domain_id: "xxx",
  name: "Test name",
  domain_enabled: true,
  inbound_domain: "test.yourdomain.com",
  inbound_address: "[email protected]",
  inbound_subdomain: "inbound",
  match_filter: {
    type: "match_all"
  },
  catch_filter: {
    type: "catch_recipient",
    filters: [
      {
        comparer: "equal",
        value: "test"
        }
    ]
  },
  forwards: [
    {
      type: "webhook",
      value: "https://www.yourdomain.com/hook"
    }
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteInbound({
  inbound_id: 'xxx'
});

Messages

Get a list of messages

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.messagesList()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get info on a message

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.message({
  message_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Scheduled Messages

Get scheduled email list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.scheduleList()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get scheduled email

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.schedule({
  message_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete scheduled email

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteSchedule({
  message_id: 'xxx'
});

Recipients

Get a list of recipients

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.recipientsList()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get single recipient

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.recipient({
  recipient_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete recipient

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteRecipient({
  recipient_id: 'xxx'
});

Add recipients to a suppression list

Blocklist

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addRecipientsToBlocklist({
  domain_id: 'xxx',
  recipients: [
    "[email protected]"
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Hard Bounces

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addRecipientsToHardBounceList({
  domain_id: 'xxx',
  recipients: [
    "[email protected]"
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Spam Complaints

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addRecipientsToSpamComplaintList({
  domain_id: 'xxx',
  recipients: [
    "[email protected]"
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Unsubscribe

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.addRecipientsToUnsubscribeList({
  domain_id: 'xxx',
  recipients: [
    "[email protected]"
  ]
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get recipients from a suppression list

Blocklist

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getRecipientsFromBlocklist({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Hard Bounce

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getRecipientsFromHardBounceList({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Spam Complaint

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getRecipientsFromSpamComplaintList({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Unsubscribe

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.getRecipientsFromUnsubscribeList({
  domain_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete recipients from a suppression list

Blocklist

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteRecipientsFromBlocklist({
  ids: [
    "xxxxxxxxxxx",
    "yyyyyyyyyyy"
  ]
});

Hard Bounce

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteRecipientsFromHardBounceList({
  ids: [
    "xxxxxxxxxxx",
    "yyyyyyyyyyy"
  ]
});

Spam Complaint

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteRecipientsFromSpamComplaintList({
  ids: [
    "xxxxxxxxxxx",
    "yyyyyyyyyyy"
  ]
});

Unsubscribe

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteRecipientsFromUnsubscribeList({
  ids: [
    "xxxxxxxxxxx",
    "yyyyyyyyyyy"
  ]
});

Templates

Get a list of templates

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.templateList()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get a single template

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.template({
  template_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete a template

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteTemplate({
  template_id: 'xxx'
});

Webhooks

Get a list of webhooks

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.webhooksList({
  domain_id: "xxx"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.webhook({
  webhook_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Create webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.createWebhook({
  url: "https://example.com",
  name: "Webhook name",
  events: ["activity.sent"],
  domain_id: "xxx"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.updateWebhook({
  webhook_id: "xxx",
  name: "New name"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

mailersend.deleteWebhook({
  webhook_id: 'xxx'
});

SMS

Send SMS

const MailerSend = require("mailersend");
const SmsParams  = require("mailersend").SmsParams;

const mailersend = new MailerSend({
  api_key: "key",
});

const recipients = [
  "+18332647501",
  "+18332647500",
];

const smsParams = new SmsParams()
      .setFrom("+18332647501")
      .setRecipients(recipients)
      .setText("This is the text content");

mailersend.sendSms(smsParams);

SMS personalization

const MailerSend = require("mailersend");
const SmsParams  = require("mailersend").SmsParams;

const mailersend = new MailerSend({
  api_key: "key",
});

const personalization = [
  {
    "phone_number": "+18332647501",
    "data": {
      "name": "Dummy"
    }
  },
  {
    "phone_number": "+18332647502",
    "data": {
      "name": "Not Dummy"
    }
  }
];

const smsParams = new SmsParams()
  .setFrom("+18332647501")
  .setRecipients(recipients)
  .setPersonalization(personalization)
  .setText("Hey {{name}} welcome to our organization");

mailersend.sendSms(smsParams);

Phone Numbers

Get phone number list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsNumbers()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get phone number

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsNumber({
  sms_number_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update phone number

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.updateSmsNumber({
  sms_number_id: 'xxx',
  paused: false
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete phone number

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.deleteSmsNumber({
  sms_number_id: 'xxx'
});

Messages

Get messages list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsMessages()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get a message

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsMessage({
  sms_message_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Activity

Get activity list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsActivities()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get activity of a message

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsActivity({
  sms_message_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Recipients

Get recipient list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsRecipients()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get recipient

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsRecipient({
  sms_recipient_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update recipient

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.updateSmsRecipient({
  sms_recipient_id: "xxx",
  status: "active"
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Webhooks

Get webhook list for a number

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsWebhooks({
  sms_number_id: 'xxx',
  limit: 10
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsWebhook({
  sms_webhook_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Create webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.createSmsWebhook({
  sms_number_id: "xxx",
  name: "Webhook",
  url: "https:://yourapp.com/hook",
  enabled: ["sms.sent", "sms.delivered", "sms.failed"],
  enabled: true
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.updateSmsWebhook({
  sms_webhook_id: "xxx",
  name: "Webhook",
  url: "https:://yourapp.com/hook",
  enabled: ["sms.sent", "sms.delivered", "sms.failed"],
  enabled: true
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete webhook

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.deleteSmsWebhook({
  sms_webhook_id: 'xxx'
});

Inbound

Get inbound list

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsInbounds()
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Get inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.getSmsInbound({
  sms_inbound_id: 'xxx'
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Add inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.createSmsInbound({
  sms_number_id: "xxx",
  name: "Inbound",
  forward_url: "https:://yourapp.com/hook",
  filter: {
    comparer: "equal",
    value: "START"
  },
  enabled: true
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Update inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.updateSmsInbound({
  sms_inbound_id: "xxx",
  name: "Inbound",
  forward_url: "https:://yourapp.com/hook",
  filter: {
    comparer: "equal",
    value: "START"
  },
  enabled: true
})
  .then(response => response.json())
  .then(data => {
    console.log(data);
  });

Delete inbound

const MailerSend = require("mailersend");

const mailersend = new MailerSend({
  api_key: "key",
});

mailersend.deleteSmsInbound({
  sms_inbound_id: 'xxx'
});

Support and Feedback

In case you find any bugs, submit an issue directly here in GitHub.

You are welcome to create SDK for any other programming language.

If you have any troubles using our API or SDK free to contact our support by email [email protected]

The official documentation is at https://developers.mailersend.com

License

The MIT License (MIT)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].