message: Allow email sink to use SES configured automatically from env vars
diff: @@ -7,6 +7,21 @@ module.exports = class EmailMessenger {
  }
  constructor(params) {
  this.params = params;
  +
  + if(params.useSes) {
  + // If SES is required, you must add aws-sdk to the consuming project
  + const aws = require("aws-sdk"); // eslint-disable-line node/no-missing-require
  + if (!params.defaultFrom) {
  + throw new Error(`Could not find defaultFrom in message sink params`);
  + }
  +
  + this.transporter = nodemailer.createTransport({
  + SES: new aws.SES({ apiVersion: '2010-12-01' })
  + }, {
  + from: params.defaultFrom
  + });
  +
  + } else {
  ['smtpPasswordEnvVar', 'smtpHost', 'smtpUser', 'defaultFrom'].forEach( prop => {
  if (!params[prop]) {
  throw new Error(`Could not find ${prop} in message sink params`);
  @@ -22,6 +37,8 @@ module.exports = class EmailMessenger {
  from: params.defaultFrom
  });
  }
  +
  + }
  async send(message) {
  log.info(`Sending mail to ${message.to}: ${message.subject}`);
  return this.transporter.sendMail(message);
  