generated from pagopa/template-java-spring-microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Prerequisites | ||
- `npm install aws-sdk` | ||
|
||
# Configuration | ||
- Create `config.json` | ||
- Set email address in the JS code | ||
|
||
# Run | ||
- `node ses_sendmail.js` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"accessKeyId": <YOUR_ACCESS_KEY_ID>, | ||
"secretAccessKey": <YOUR_SECRET_ACCESS_KEY>, | ||
"region": "eu-south-1" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Load the AWS SDK for Node.js | ||
var AWS = require('aws-sdk'); | ||
|
||
AWS.config.loadFromPath('./config.json'); | ||
|
||
// Create sendEmail params | ||
var params = { | ||
Destination: { /* required */ | ||
CcAddresses: [ | ||
/* more items */ | ||
], | ||
ToAddresses: [ | ||
'<CHANGE_ME>', | ||
/* more items */ | ||
] | ||
}, | ||
Message: { /* required */ | ||
Body: { /* required */ | ||
Html: { | ||
Charset: "UTF-8", | ||
Data: "HTML_FORMAT_BODY" | ||
}, | ||
Text: { | ||
Charset: "UTF-8", | ||
Data: "TEXT_FORMAT_BODY" | ||
} | ||
}, | ||
Subject: { | ||
Charset: 'UTF-8', | ||
Data: 'Test email' | ||
} | ||
}, | ||
Source: '<CHANGE_ME>', /* required */ | ||
ReplyToAddresses: [ | ||
/* more items */ | ||
], | ||
}; | ||
|
||
// Create the promise and SES service object | ||
var sendPromise = new AWS.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise(); | ||
|
||
// Handle promise's fulfilled/rejected states | ||
sendPromise.then( | ||
function(data) { | ||
console.log(data.MessageId); | ||
}).catch( | ||
function(err) { | ||
console.error(err, err.stack); | ||
}); |