AWS SDK for JavaScript SES Client for Node.js, Browser and React Native
npx @tessl/cli install tessl/npm-aws-sdk--client-ses@3.879.0The AWS SDK for JavaScript SES Client provides a comprehensive API for Amazon Simple Email Service (SES), enabling developers to send emails, manage identities, configure receipt processing, create templates, and analyze email performance. This package offers both low-level command-based and high-level aggregated client interfaces with full TypeScript support for Node.js, browser, and React Native environments.
npm install @aws-sdk/client-sesimport { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";For aggregated client:
import { SES } from "@aws-sdk/client-ses";CommonJS:
const { SESClient, SendEmailCommand } = require("@aws-sdk/client-ses");import { SESClient, SendEmailCommand } from "@aws-sdk/client-ses";
// Initialize client
const client = new SESClient({ region: "us-east-1" });
// Send an email
const command = new SendEmailCommand({
Source: "sender@example.com",
Destination: {
ToAddresses: ["recipient@example.com"],
},
Message: {
Subject: { Data: "Test Email" },
Body: {
Text: { Data: "Hello from AWS SES!" },
},
},
});
try {
const response = await client.send(command);
console.log("Email sent successfully:", response.MessageId);
} catch (error) {
console.error("Error sending email:", error);
}The AWS SES SDK is built around several key components:
SESClient for command-based operations and SES for convenient method shortcutsCore email sending functionality with support for formatted emails, raw emails with attachments, templated emails, and bulk operations.
interface SendEmailCommandInput {
Source: string;
Destination: Destination;
Message: Message;
ReplyToAddresses?: string[];
ReturnPath?: string;
Tags?: MessageTag[];
ConfigurationSetName?: string;
}
interface Destination {
ToAddresses?: string[];
CcAddresses?: string[];
BccAddresses?: string[];
}
interface Message {
Subject: Content;
Body: Body;
}
interface Content {
Data: string;
Charset?: string;
}
interface Body {
Text?: Content;
Html?: Content;
}Comprehensive identity verification and configuration system for email addresses and domains, including DKIM, Mail-From domain setup, and authorization policies.
interface VerifyEmailIdentityCommandInput {
EmailAddress: string;
}
interface VerifyDomainIdentityCommandInput {
Domain: string;
}
interface GetIdentityVerificationAttributesCommandInput {
Identities: string[];
}
interface IdentityVerificationAttributes {
VerificationStatus: VerificationStatus;
VerificationToken?: string;
}Email template system for creating reusable email formats with variable substitution and bulk email operations.
interface CreateTemplateCommandInput {
Template: Template;
}
interface Template {
TemplateName: string;
Subject?: string;
TextPart?: string;
HtmlPart?: string;
}
interface SendTemplatedEmailCommandInput {
Source: string;
Destination: Destination;
Template: string;
TemplateData: string;
ConfigurationSetName?: string;
}Email tracking and analytics configuration with event destinations, reputation metrics, and delivery options for detailed email performance monitoring.
interface CreateConfigurationSetCommandInput {
ConfigurationSet: ConfigurationSet;
}
interface ConfigurationSet {
Name: string;
}
interface CreateConfigurationSetEventDestinationCommandInput {
ConfigurationSetName: string;
EventDestination: EventDestination;
}
interface EventDestination {
Name: string;
Enabled?: boolean;
MatchingEventTypes: EventType[];
CloudWatchDestination?: CloudWatchDestination;
KinesisFirehoseDestination?: KinesisFirehoseDestination;
SNSDestination?: SNSDestination;
}Comprehensive email receipt processing system with rules, rule sets, and actions for handling incoming emails automatically.
interface CreateReceiptRuleCommandInput {
RuleSetName: string;
After?: string;
Rule: ReceiptRule;
}
interface ReceiptRule {
Name: string;
Enabled?: boolean;
TlsPolicy?: TlsPolicy;
Recipients?: string[];
Actions?: ReceiptAction[];
ScanEnabled?: boolean;
}
interface ReceiptAction {
S3Action?: S3Action;
BounceAction?: BounceAction;
LambdaAction?: LambdaAction;
SNSAction?: SNSAction;
AddHeaderAction?: AddHeaderAction;
WorkmailAction?: WorkmailAction;
StopAction?: StopAction;
}interface SESClientConfig {
region?: string;
credentials?: AwsCredentialIdentityProvider;
endpoint?: string;
maxAttempts?: number;
logger?: Logger;
requestHandler?: RequestHandler;
}
class SESClient {
constructor(configuration: SESClientConfig);
send<InputType, OutputType>(
command: Command<InputType, OutputType>
): Promise<OutputType>;
destroy(): void;
}type VerificationStatus = "Pending" | "Success" | "Failed" | "TemporaryFailure" | "NotStarted";
type IdentityType = "EmailAddress" | "Domain";
type EventType = "send" | "reject" | "bounce" | "complaint" | "delivery" | "click" | "open" | "renderingFailure";
type TlsPolicy = "Require" | "Optional";
type BounceType = "DoesNotExist" | "MessageTooLarge" | "ExceededQuota" | "ContentRejected" | "Undefined" | "TemporaryFailure";
type NotificationType = "Bounce" | "Complaint" | "Delivery";class SESServiceException extends Error {
name: string;
message: string;
$fault: "client" | "server";
$metadata: ResponseMetadata;
}
class MessageRejected extends SESServiceException {}
class LimitExceededException extends SESServiceException {}
class AccountSendingPausedException extends SESServiceException {}
class ConfigurationSetDoesNotExistException extends SESServiceException {}
class TemplateDoesNotExistException extends SESServiceException {}Account-level sending statistics, quotas, and monitoring capabilities for tracking email performance and compliance.
interface GetSendQuotaCommandOutput {
Max24HourSend?: number;
MaxSendRate?: number;
SentLast24Hours?: number;
}
interface GetSendStatisticsCommandOutput {
SendDataPoints?: SendDataPoint[];
}
interface SendDataPoint {
Timestamp?: Date;
DeliveryAttempts?: number;
Bounces?: number;
Complaints?: number;
Rejects?: number;
}Utilities for handling large result sets and waiting for asynchronous operations to complete.
function paginateListIdentities(
config: SESPaginationConfiguration,
input: ListIdentitiesCommandInput
): Paginator<ListIdentitiesCommandOutput>;
function waitForIdentityExists(
params: WaiterConfiguration<SESClient>,
input: GetIdentityVerificationAttributesCommandInput
): Promise<WaiterResult>;