@absolute/cloud-mail-service
v0.0.2
Published
This package provides Node.js server side SDK for sending emails using AWS-SES/Nodemailer and to log sending emails using @Absolute ChangeTracker library
Downloads
5
Readme
Absolute - CloudMailService - Node.js SDK
This package provides Node.js server side SDK for sending emails using AWS-SES/Nodemailer and to log sending emails using @Absolute ChangeTracker library
Install
npm install --save @absolute/cloud-mail-service
Documentation
After package installing set the config and use the maker to initialize the service:
Notes:
- If you run this package on AWS Lambda function aws_ configs are not required.
- If you don't set ct_account config the package will send the email without logs.
- ct_table_name is the table where ChangeTracker will store emails logs. Default value: 'log_email'.
const config = {
aws_region: '[YOUR_AWS_REGION]',
aws_secret_access_key: '[YOUR_AWS_SECRET_ACCESS_KEY]',
aws_access_key_id: '[YOUR_AWS_ACCESS_KEY_ID]',
ct_account: '[YOUR_CT_ACCOUNT_ID]',
ct_api_secret_post: '[YOUR_CT_SECRET_POST]',
ct_api_secret_get: '[YOUR_CT_SECRET_GET]',
ct_table_name: '[YOUR_CT_LOG_TABLE_NAME]'
};
const sendEmail = makeCloudMailService(config);
To send email call the function is this way:
const sendResponse = await sendEmail({
from: 'from_email_address',
to: ['to_email_address', ...],
cc: ['cc_email_address', ...],
bcc: ['bcc_email_address', ...],
subject: 'msg_subject',
body: 'msg_body (plain string or html)',
attachments: ['see nodemailer docs for attachments - https://nodemailer.com/message/attachments/'],
senderName: 'sender_name',
replyTo: 'reply_to_email_address',
html: 'set true if body is html'
});
To retrieve and display email logs you can use @absolute/change-tracker NPM Package.
Docs here: https://www.npmjs.com/package/@absolute/change-tracker