Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello guys, I'm kind of stuck, I'm trying to send a password reset email using AWS SES in Next.js. But I am getting the error below:

MultipleValidationErrors: There were 2 validation errors:
* MissingRequiredParameter: Missing required key 'Message' in params
* UnexpectedParameter: Unexpected key 'message' found in params


What I have tried:

Dotenv:

<pre>AWS_ACCESS_KEY_ID=keyID_here
AWS_SECRET_ACCESS_KEY=key_here
AWS_REGION='region_here'
AWS_API_VERSION='version_here'

EMAIL_FROM=email_here



Main Code:

import User from '../models/user';
import { hashPassword, comparePassword } from '../utils/auth';
import jwt from 'jsonwebtoken';
import AWS from 'aws-sdk';

const awsConfig = {
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_ACCESS_KEY_ID,
  region: process.env.AWS_REGION,
  apiVersion: process.env.AWS_API_VERSION,
};

const SES = new AWS.SES(awsConfig);

export const sendTestEmail = (req, res) => {

  let params = {
    Source: process.env.EMAIL_FROM,
    Destination: {
      ToAddresses: ['email_to_send_to'],
    },
    ReplyToAddresses: [process.env.EMAIL_FROM],
    message: {
      Body: {
        Html: {
          Charset: 'UTF-8',
          Data: `
            <html>
              <h1> Reset Password Link </h1>
              <p> Kindly use the link below to reset your password <p/>
            </html>
          `,
        },
      },
      Subject: {
        Charset: 'UTF-8',
        Data: `Reset Password Link`,
      },
    },
  };

  const emailSent = SES.sendEmail(params).promise();

  emailSent
    .then((data) => {
      console.log(data);
      res.json({ ok: true });
    })
    .catch((err) => {
      console.log(err);
    });
};
Posted
Updated 11-Nov-21 1:39am
Comments
Member 15329613 10-Nov-21 16:57pm    
I have not used this technology but from the error message it would indicate that you need to change "message" to "Message", right?
Amogs 10-Nov-21 18:14pm    
Thanks man. Funny enough, I had looked at the said 'm' a thousand times today and my mind was showing me a capital 'm'. Not until you confirmed to me it was a small 'm', I changed it and it worked immediately.
Member 15329613 11-Nov-21 7:38am    
Ha! That's happened to all of us. No worries. Glad it worked.

1 solution

As mentioned in the comments, the lower case 'm' should be an upper case 'M' on message.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900