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);
});
};