1.1.0 • Published 4 years ago
ses-email-client v1.1.0
SES Email Client
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: 'mock@email.com',
to: 'test@email.com',
subject: 'Hello World',
text: 'Hello World',
});
Message options
- from
string
- to
string
orstring []
- cc
string
orstring []
- bcc
string
orstring []
- 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"]
Changelog
Example
You can also check an example usage.
Issues
For any issues.
License
MIT License