Giter Site home page Giter Site logo

gkampitakis / ses-email-client Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 2.0 35 KB

Wrapper for sending emails with AWS SES supporting templates

Home Page: https://www.npmjs.com/package/ses-email-client

License: MIT License

JavaScript 98.76% Handlebars 1.05% EJS 0.18%
aws-ses emails ejs-templates mjml-template handlebars-template npm-package

ses-email-client's Introduction

SES Email Client

js-semistandard-style

Description

ses-email-client is a wrapper for sending emails with AWS SES supporting templates.

Supported Templates

  • mjml
  • handlebars
  • ejs

Install

npm i ses-email-client

Usage

Instantiate Client

All settings are optional

// or ES6 syntax import SESEmailClient from 'ses-email-client';
const SESEmailClient = require('ses-email-client');
const client = new SESEmailClient({
    accessKeyId: '**********',
    secretAccessKey: '**********',
    region: 'eu-west-2',
    templateLanguage: 'handlebars', // 'mjml', 'ejs'
    production: true, // or process.env.NODE_ENV = production is as setting to true
    tmpltCacheSize: 50, // template cache size default = 100
    attCacheSize: 50, // attachment cache size default = 100
});

Note that in production mode either by explicitly setting it to true or by setting NODE_ENV = production ses-email-client will cache template and attachment files.

For AWS you can skip providing credentials as the aws-sdk is used so you can opt for other ways for authorizing.

For more info you can check setting-credentials-node.

Send an email

await client.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Hello World',
    text: 'Hello World',
});

Message options

  • from string
  • to string or string []
  • cc string or string []
  • bcc string or string []
  • text string
  • html string
  • subject string
  • template string the path of the html template you want to use
  • data object an object containing the data that the template is going to be compiled with
  • subject string
  • attachments
[
    {
        name: 'myfilte.txt', // optional if not provided will keep filename
        path: __dirname + '/path/to/file',
    },
][
    // or
    (__dirname + '/path/to/file', 'another/file')
];

Example

You can also check an example usage.

Issues

For any issues.

License

MIT License

ses-email-client's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar gkampitakis avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

jsfix-ci

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.