I need to send emails to many users, how to send them using Amazon SES API v2.
I created a contact list with a topic and created contact and I tried to send an email. It's throwing an error, I don't know where it went wrong. There are not enough resources out there.
Below is my code:
const SesV2 = new AWS.SESV2({ apiVersion: "2019-09-27" });
const sendEmailforTemplates = async (subject, template = "") => {
const params = {
Content: {
Simple: {
Body: {
Html: {
Data: template /* required */,
Charset: "UTF-8",
},
},
Subject: {
Charset: "UTF-8",
Data: subject,
},
},
},
FeedbackForwardingEmailAddress: "myemail@mydomain.com",
FromEmailAddress: "support@mydomain.com",
ListManagementOptions: {
ContactListName: "contact_list" /* required */,
TopicName: "users_topic",
},
};
try {
const data = await SesV2.sendEmail(params).promise();
return data;
} catch (error) {
throw error;
}
};
sendEmailforTemplates(
"Test Subject",
`
<!DOCTYPE html>
<html>
<head>
<title>
First Web Page
</title>
</head>
<body>
Hello World Testing Message !!!
</body>
</html>`
)
.then((result) => {
console.log("RESULT", result);
})
.catch((err) => {
console.log("error", err.stack);
});
Can someone help me on how to send emails to many users at once and tell me what I did wrong?