Skip to content

Instantly share code, notes, and snippets.

@badri
Created March 31, 2025 08:58
Show Gist options
  • Save badri/8a67b72ec75273efd7762b4a07341b25 to your computer and use it in GitHub Desktop.
Save badri/8a67b72ec75273efd7762b4a07341b25 to your computer and use it in GitHub Desktop.
AWS SES sdk
const { SESClient, SendEmailCommand } = require("@aws-sdk/client-ses");
const ses = new SESClient({
region: "ap-south-1",
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
},
});
async function sendEmail() {
const command = new SendEmailCommand({
Source: "[email protected]",
Destination: {
ToAddresses: ["[email protected]"],
},
Message: {
Subject: { Data: "Hello from SES via SDK" },
Body: {
Text: { Data: "This email was sent using the SES SDK from DigitalOcean Kubernetes." },
},
},
});
try {
const res = await ses.send(command);
console.log("Email sent! Message ID:", res.MessageId);
} catch (err) {
console.error("Failed to send email:", err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment