Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sendEmail = function(to, subject, message) {
// Log
console.log('Sending email', to, subject, message);
const client = ses.createClient({ amazon: AWS_SES_ENDPOINT, key: AWS_SES_KEY, secret: AWS_SES_SECRET });
client.sendEmail({
to,
//to: 'success@simulator.amazonses.com',
from: AWS_SES_FROM_ADDRESS,
subject,
message
}, function(err, data, res) { console.log(err, data) });
// TODO should we switch to promise-based SES module to be able to return success/failure?
}
init: config => {
var client = nodeSES.createClient({
key: config.amazon_ses_api_key,
secret: config.amazon_ses_secret,
amazon: config.amazon_ses_endpoint,
});
return {
send: (options, cb) => {
return new Promise((resolve, reject) => {
// Default values.
options = _.isObject(options) ? options : {};
options.from = options.from || config.amazon_ses_default_from;
options.replyTo =
options.replyTo || config.amazon_ses_default_replyto;
options.text = options.text || options.html;
options.html = options.html || options.text;
return new Promise(function(resolve, reject) {
// Actually send the email
ses.sendEmail(email, function(err, data, res) {
if (err) {
// Failed
return reject(err);
}
// Success
return resolve(data);
});
});
};
import { readFile } from "fs-extra";
import { join } from "path";
import { render } from "mustache";
import marked from "marked";
import { isMatch } from "matcher";
import disposableDomains from "disposable-email-domains/index.json";
import wildcardDomains from "disposable-email-domains/wildcard.json";
import i18n from "../i18n";
import Joi from "@hapi/joi";
import { joiValidate } from "./utils";
import { DISPOSABLE_EMAIL } from "@staart/errors";
import { logError } from "./errors";
import systemInfo from "systeminformation";
import pkg from "../../package.json";
const client = createClient({
key: SES_ACCESS,
secret: SES_SECRET,
amazon: `https://email.${SES_REGION}.amazonaws.com`
});
/**
* Send a new email using AWS SES
*/
const sendMail = (mail: Mail): Promise =>
new Promise((resolve, reject) => {
client.sendEmail(
mail,
(error: SendEmailError, data: SendEmailData, response: Response) => {
if (error) return reject(error);
resolve(response);
}