Skip to content

Instantly share code, notes, and snippets.

@NicolasVanhecke
Last active June 14, 2021 13:16
Show Gist options
  • Save NicolasVanhecke/62335a3d812b9b35558f8fd7076a38be to your computer and use it in GitHub Desktop.
Save NicolasVanhecke/62335a3d812b9b35558f8fd7076a38be to your computer and use it in GitHub Desktop.
const AWS = require( 'aws-sdk' );
class MailHelper {
constructor() {
//
}
/**
* Send mail to flightOps ( depending on which airline ) via AWS SES
*
* @param {Flight} flight
*
* @returns {object | null}
*/
async sendMailToFlightOps( flight ) {
const ses = new AWS.SES();
let params = {
ReplyToAddresses: [ 'noreply@dev.ofp.aviation.tui' ],
Source: 'MissingFlightReturnData@dev.ofp.aviation.tui',
Destination: {
ToAddresses: ['nicolas.vanhecke@tui.be']
},
Message: {
Subject: {
Charset: 'UTF-8',
Data: 'Missing Flight Return Data for ' + flight.getFlightNumber() + ' ' + flight.getDeparture() + '-' + flight.getDestination() + ' ' + flight.getFlightDate(),
},
Body: {
Html: {
Charset: 'UTF-8',
Data: '<h2>Example h2 title</h2>' +
'<p>An example of sending email with ses and aws-sdk on Node.js : <a class="ulink" href="https://github.com/mdhelaluddin-ctg-bd/ses-email-nodejs" target="_blank">Check here</a></p>.' +
'<p>This is a second paragraph.</p>'
},
Text: {
Charset: 'UTF-8',
Data: 'An example of sending email with ses and aws-sdk on Node.js.'
}
}
}
};
return ses.sendEmail( params ).promise().then(
output => {
console.log( 'goed' );
console.log( output );
return output;
},
err => {
console.error( 'slecht' );
console.error( err );
return err;
}
);
}
}
module.exports = MailHelper;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment