0.0.3 • Published 2 years ago

amply.js v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
2 years ago

Amply.js

This is the Amply Javascript SDK that integrates with the v1 API.

Table of Contents

Install

Prerequisites

Access Token

Obtain your access token from the Amply UI.

Install Package

npm install amply.js

Domain Verification

Add domains you want to send from via the Verified Domains tab on your dashboard.

Any emails you attempt to send from an unverified domain will be rejected. Once verified, Amply immediately starts warming up your domain and IP reputation. This warmup process will take approximately one week before maximal deliverability has been reached.

Quick Start

The following is the minimum needed code to send a simple email. Use this example, and modify the to and from variables:

const amply = require ('amply.js');
amply.setAccessToken(process.env.AMPLY_ACCESS_TOKEN);

//ES6
amply.email.create({
  to: 'test@example.com',
  from: 'test@verifieddomain.com',
  subject: 'My first Amply email!',
  text: 'This is easy',
  html: '<strong>and fun :)</strong>'
}).then(msg => console.log(msg))
.catch(err => console.log(err.response));

Once you execute this code, you should have an email in the inbox of the recipient. You can check the status of your email in the UI from the Search, SQL, or Users page.

Methods

email

Parameter(s)Description
to, cc, bccEmail address of the recipient(s). This may be a string Test <test@example.com>, an object {name: 'Test', email: 'test@example.com'}, or an array of strings and objects.
personalizationsFor fine tuned access, you may override the to, cc, and bcc keys and use advanced personalizations. See the API guide here.
fromEmail address of the sender. This may be formatted as a string or object. An array of senders is not allowed.
subjectSubject of the message.
htmlHTML portion of the message.
textText portion of the message.
contentAn array of objects containing the following keys: type (required), value (required).
templateThe template to use. This may be a string (the UUID of the template), an array of UUID's (useful for A/B/... testing where one is randomly selected), or an object of the format {template1Uuid: 0.25, template2Uuid: 0.75} (useful for weighted A/B/... testing).
dynamicTemplateDataThe dynamic data to be replaced in your template. This is an object of the format {variable1: 'replacement1', ...}. Variables should be defined in your template body using handlebars syntax {{variable1}}.
replyToEmail address of who should receive replies. This may be a string or an object with name and email keys.
headersAn object where the header name is the key and header value is the value.
ipOrPoolUuidThe UUID of the IP address or IP pool you want to send from. Default is your Global pool.
unsubscribeGroupUuidThe UUID of the unsubscribe group you want to associate with this email.
attachmentsA base64 encoded string of your attachment's content.
attachmentsThe MIME type of your attachment.
attachmentsThe filename of your attachment.
attachmentsThe disposition of your attachment (inline or attachment).
attachmentsThe content ID of your attachment.
clicktrackingEnable or disable clicktracking.
categoriesAn array of email categories you can associate with your message.
substitutionsAn object of the format {subFrom: 'subTo', ...} of substitutions.
sendAtDelay sending until a specified time. An ISO8601 formatted string with timezone information.

Example

amply.email.create({
  to:   'example@test.com',
  from: 'From <example@verifieddomain.com>',
  text: 'Text part',
  html: 'HTML part',
  personalizations: [{to: [{name: 'Override To', email: 'test@example.com'}]}],
  content: [{type: 'text/testing', value: 'some custom content type'}],
  subject: 'A new email!',
  replyTo: 'Reply To <test@example.com>',
  template: 'faecb75b-371e-4062-89d5-372b8ff0effd',
  dynamicTemplateData: {name: 'Jimmy'},
  unsubscribeGroupUuid: '5ac48b43-6e7e-4c51-817d-f81ea0a09816',
  ipOrPoolUuid: '2e378fc9-3e23-4853-bccb-2990fda83ca9',
  attachments: [{content: 'dGVzdA==', filename: 'test.txt', type: 'text/plain', disposition: 'inline'}],
  headers: {'X-Testing': 'Test'},
  categories: ['Test'],
  clicktracking: true,
  substitutions: {'sub1': 'replacement1'},
  sendAt: "2021-06-23T15:26:03-07:00"
}).then(msg => console.log(msg))
.catch(err => console.log(err.response));
0.0.3

2 years ago

0.0.2-rc.8

3 years ago

0.0.2-rc.7

3 years ago

0.0.2-rc.6

3 years ago

0.0.2-rc.5

3 years ago

0.0.2-rc.4

3 years ago

0.0.2-rc.3

3 years ago

0.0.2-rc.2

3 years ago

0.0.2-rc.1

3 years ago

0.0.1

3 years ago