Simplecode Community Forums

Create a REST API [Part 4]: Send Emails with Amazon SES

Download the code for this series

Amazon's simple email service (Amazon SES) allows developers to programmatically send emails through Amazon's servers from any email address that they have verified in their AWS account. In this tutorial you will create a utility function to send emails through Amazon SES and when ever a user is registered through your API, an email will be sent to their email address with a token to verify them with. Let's get started.


This is a companion discussion topic for the original entry at https://www.simplecode.io/blog/create-a-rest-api-part-4-send-emails-with-amazon-ses

In Postman, if i send a post body with a dummy email,

{
  "email": "info@gmail.com",
  "password1": "12345678#",
  "password2": "12345678#"
}

I get back success.

I send with an email i registered on ses, i get,

{
  "email": "verifiedonses@gmail.com",
  "password1": "12345678#",
  "password2": "12345678#"
}
{
    "email": "Email address is invalid",
    "password1": "Passwords must be greater than 8 characters",
    "password2": "Confirmation password is required"
}

Can you point me to what is going on here?

I dug a bit and learned that the aws set up is not returning any variables.

https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/global-config-object.html

console.log("Region: ", aws.config.region); returns undefined.

So in order to get those variables to show up I had to

export AWS_SDK_LOAD_CONFIG=true in the same terminal you are running the server in.

Then your variables become available.

console.log("Region: ", aws.config);
console.log("Region: ", aws.config.region);
console.log("accessKeyId: ", aws.config.credentials.accessKeyId);
console.log("secretAccessKey: ", aws.config.credentials.secretAccessKey);

Thanks.

1 Like

Glad you were able to fix it @idkjs and thanks for posting your solution. I haven’t been able to recreate this. Wondering if anyone else is running in this issue?