0.0.8 • Published 8 years ago
aws-ses-helper v0.0.8
aws-ses-helper
This is a simple npm module with set of helpers for Amazon Simple Email Service (Amazon SES).
Installation guide
npm install aws-ses-helper
Usage
Just include the library along to aws-sdk:
const AWS = require('aws-sdk');
const ASH = require('aws-ses-helper');
EmailSender
Follow this example to send email by AWS.SES:
let config = {
sourceEmail: 'qa@gmail.com:QA department',
destinationEmails: 'support@gmail.com, admin@gmail.com:Admin',
subject: 'Email subject',
body: '<div>Email body</div>'
};
let sender = new ASH.EmailSender(new AWS.SES(), config);
sender.sendEmail().then(res => {
// response
}).catch(err => {
// error
});
CaptchaChecker
If you want to use Google reCaptcha, just validate your captcha response and then send your email:
const captchaSecret = 'your_google_captcha_secret_here';
const captchaResponse = 'your_google_captcha_response_here';
let checker = new ASH.CaptchaChecker(captchaSecret, captchaResponse);
checker.checkCaptcha().then(res => {
// response from google
}).catch(err => {
// request error
});
EmailTemplate
Let's assume that we have following email template:
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"></head>
<body>
Hello, {{ Name }}!
</body>
</html>
To render it, just do this:
let tmpl = new ASH.EmailTemplate('message.twig', {
Name: 'Linus Torvalds'
});
tmpl.render().then(res => {
// rendered html response
}).catch(err => {
// request error
});
Improvements
Have an idea how to improve this module?
Feel free to contribute or open an issue with enhancement
label.
License
This repository can be used under the MIT license.
See LICENSE for more details.