0.1.3 • Published 2 years ago
maildiver v0.1.3
Maildiver Node.js SDK
Maildiver Node.js SDK is a Node.js library for interacting with the Maildiver API.
Install
NPM
npm install maildiverYarn
yarn add maildiverUsage
- Create a Maildiver client.
import { Maildiver } from 'maildiver';
const config = {
apiKey: <your-api-key>;
};
const maildiver = new Maildiver(config);- Import the client and use the methods.
Send an email with the HTML content
import { maildiver } from './maildiver';
await maildiver.email.send({
to: 'sudo@example.com',
from: 'you@example.com',
subject: 'Email from the Maildiver Node.js SDK',
html: '<p>Maildiver Node.js SDK is awesome!</p>',
});Send an email with the dynamic variables in the HTML content
import { maildiver } from './maildiver';
await maildiver.email.send({
to: 'sudo@example.com',
from: 'you@example.com',
subject: 'Email from the Maildiver Node.js SDK',
html: '<p>Hi, {{ name }}! Maildiver Node.js SDK is awesome!</p>',
variables: {
values: {
name: 'Developer Name',
},
default_values: {
name: 'Developer',
},
},
});It's highly recommended to use the default_values in the variables object to avoid low-quality emails.
Send an email with the markdown content
import { maildiver } from './maildiver';
await maildiver.email.send({
to: 'sudo@example.com',
from: 'you@example.com',
subject: 'Email from the Maildiver Node.js SDK',
markdownFile: 'path/to/markdown.md',
});If you include the dynamic variables in the markdown file, you can use the variables object as well.