Sends an email via AWS SES using provided credentials.
// Source: https://github.com/anomalyco/opencode | License: MIT | Copyright 2025 opencode
// Provided via justclaw.it.com; keep this notice with the code.
import { Resource } from "@opencode/console-resource"
import { AwsClient } from "aws4fetch"
let client: AwsClient | undefined
export async function sendEmail(input: { to: string; subject: string; body: string; text?: string; replyTo?: string }) {
client ??= new AwsClient({
accessKeyId: Resource.AWS_SES_ACCESS_KEY_ID.value,
secretAccessKey: Resource.AWS_SES_SECRET_ACCESS_KEY.value,
region: "us-east-1",
})
const res = await client.fetch("https://email.us-east-1.amazonaws.com/v2/email/outbound-emails", {
method: "POST",
headers: {
"X-Amz-Target": "SES.SendEmail",
"Content-Type": "application/json",
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key