NodeJS SMTP Email API SDK
Mailazy NodeJs SDK Client
Table of Contents
Install
Prerequisites
Generate Access Keys
You need a sender/domain authenticated account in order to generate Access Keys from the Mailazy Console
Install Package
npm:
npm install smtp-mailer
yarn:
yarn add smtp-mailer
Usage
Email API
const MailazyClient = require('smtp-mailer');
const client = new MailazyClient({
serviceType: "API",
auth: {
user: '___mailazy_access_key___',
pass: '___mailazy_access_secret___'
}
});
const fn = async () => {
try {
const resp = await client.send({
from: "example@domain.com",
to: "test@example.com",
cc: "cc@domain.com",
bcc: "bcc@domain.com",
reply_to: "reply@domain.com",
subject: 'test email from node.js app with attachment',
text: 'hello world!',
html: '<b>hello world</b>',
attachments: [
{
filename: 'hello.csv',
path: path.join(__dirname, `hello.csv`),
contentType: 'application/octet-stream'
}
]
});
console.log('resp: ' + resp);
} catch (e) {
console.log('error: ' + e);
}
};
fn();
SMTP
const MailazyClient = require('smtp-mailer');
const client = new MailazyClient({
serviceType: "SMTP",
auth: {
user: '___mailazy_access_key___',
pass: '___mailazy_access_secret___'
}
});
const fn = async () => {
try {
const resp = await client.send({
from: "example@domain.com",
to: "test@example.com",
cc: "cc@domain.com",
bcc: "bcc@domain.com",
reply_to: "reply@domain.com",
subject: 'test email from node.js app with attachment',
text: 'hello world!',
html: '<b>hello world</b>',
attachments: [
{
filename: 'hello.csv',
path: path.join(__dirname, `hello.csv`),
contentType: 'application/octet-stream'
}
]
});
console.log('resp: ' + resp);
} catch (e) {
console.log('error: ' + e);
}
};
fn();
License
MIT © Mailazy