Created
March 31, 2025 08:58
-
-
Save badri/8a67b72ec75273efd7762b4a07341b25 to your computer and use it in GitHub Desktop.
AWS SES sdk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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