Skip to content

mailazy/NodeJS-SMTP-Email-API-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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", //SMTP,API
    auth: {
        user: '___mailazy_access_key___',
        pass: '___mailazy_access_secret___'
    }
});

const fn = async () => {
    try {
        const resp = await client.send({
           from: "example@domain.com", // required, Use domain you verified
           to: "test@example.com", // required, user comma (,) for multiple recipients
           cc: "cc@domain.com", // optional, user comma (,) for multiple recipients
           bcc: "bcc@domain.com", // optional, user comma (,) for multiple recipients
           reply_to: "reply@domain.com", // optional
           subject: 'test email from node.js app with attachment', // required
           text: 'hello world!', // required
           html: '<b>hello world</b>', // required
           attachments: [ // optional
           {
               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", //SMTP,API
    auth: {
        user: '___mailazy_access_key___',
        pass: '___mailazy_access_secret___'
    }
});

const fn = async () => {
    try {
        const resp = await client.send({
           from: "example@domain.com", // required, Use domain you verified
           to: "test@example.com", // required, user comma (,) for multiple recipients
           cc: "cc@domain.com", // optional, user comma (,) for multiple recipients
           bcc: "bcc@domain.com", // optional, user comma (,) for multiple recipients
           reply_to: "reply@domain.com", // optional
           subject: 'test email from node.js app with attachment', // required
           text: 'hello world!', // required
           html: '<b>hello world</b>', // required
           attachments: [ // optional
           {
               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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published