Last active
September 20, 2019 06:09
-
-
Save OttlikG/0197878b295d0828fd248236a0d196ff to your computer and use it in GitHub Desktop.
Medium post: Use AWS SES with GoDaddy and Gatsby
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
sendEmail = () => { | |
window.AWS.config.region = "eu-west-1" // Region | |
window.AWS.config.credentials = new window.AWS.CognitoIdentityCredentials( | |
{ | |
IdentityPoolId: | |
"eu-west-1:00000000-0000-0000-0000-000000000000", | |
} | |
) | |
const name = this.name.current.value | |
const email = this.email.current.value | |
const message = this.message.current.value | |
window.AWS.config.credentials.get(function(err) { | |
if (!err) { | |
var ses = new window.AWS.SES({ | |
apiVersion: "2010-12-01", | |
}) | |
var params = { | |
Destination: { | |
ToAddresses: ["[email protected]"], | |
}, | |
Message: { | |
Body: { | |
Html: { | |
Charset: "UTF-8", | |
Data: message, | |
}, | |
Text: { | |
Charset: "UTF-8", | |
Data: "This is the message body in text format.", | |
}, | |
}, | |
Subject: { | |
Charset: "UTF-8", | |
Data: `Message from: ${name}`, | |
}, | |
}, | |
Source: email, | |
} | |
ses.sendEmail(params, function(err, data) { | |
if (err) console.log(err, err.stack) | |
}) | |
} | |
}) |
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
<Helmet> | |
<script | |
id="sdk.amazonaws" | |
src="https://sdk.amazonaws.com/js/aws-sdk-2.527.0.min.js" | |
/> | |
</Helmet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment