Last active
June 14, 2021 13:16
-
-
Save NicolasVanhecke/62335a3d812b9b35558f8fd7076a38be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [ '[email protected]' ], | |
Source: '[email protected]', | |
Destination: { | |
ToAddresses: ['[email protected]'] | |
}, | |
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