Email archiving
Email archiving stores copies of selected inbound and outbound email in managed, searchable storage. You can retain messages for a configured period, find messages with header and SMTP envelope filters, download individual messages, and export matching messages to an S3 bucket.
An archive can contain both sent and received email. Create the archive before you reference it from a Mail Manager rule or an SES configuration set.
You can add email to an archive from the following paths.
-
Sent email archiving – Archiving options on an SES configuration set submit a copy of each email sent with that configuration set.
-
Received email archiving – After an ingress endpoint's traffic policy accepts a recipient, the assigned rule set processes the email. An Archive action submits a copy of email selected by the rule's conditions to its target archive.
How email enters an archive
For inbound email, a traffic policy first accepts the recipient. The assigned rule set then evaluates its conditions and runs its actions in order. An Archive action submits a copy of the current message to its target archive. For outbound email, the archiving options on the configuration set submit a copy of each email sent with that configuration set.
The following diagram shows recommended patterns for using Archive with other rule actions.
-
Place Add header before Archive when the archived copy must contain the added header.
-
Place Archive before Drop. Drop stops processing for the selected recipients, so later actions do not run for those recipients.
-
Use one Archive action in a common rule when every accepted message has the same retention requirements. Each Archive action that runs submits a separate archive request.
-
Use separate archives when email needs different retention periods or customer managed AWS KMS keys.
Archive is asynchronous. Completion of the Archive action confirms that Mail
Manager accepted the archive request. It does not confirm that durable storage has
completed. ActionFailurePolicy does not cover a storage failure that
occurs after the request is accepted. Verify customer managed AWS KMS key access and
test representative searches before relying on the archive.
For Archive action fields and a complete rule-set example, see Archive. To configure outbound email archiving, see Create a configuration set (console) and Create a configuration set (AWS CLI).
Permissions for archives, searches, and exports
Grant the calling principal the Mail Manager action that corresponds to each command.
For example, archive creation uses ses:CreateArchive, search uses
ses:StartArchiveSearch, ses:GetArchiveSearch, and
ses:GetArchiveSearchResults, and export uses
ses:StartArchiveExport and ses:GetArchiveExport. Grant
ses:GetArchiveMessage and ses:GetArchiveMessageContent when
the principal must retrieve message data.
A customer managed AWS KMS key and an export destination bucket require additional key and bucket permissions. For the required policies, see Permission policies for Email archiving.
Creating an archive with the AWS CLI
The following command creates an archive that retains email for seven years. Replace
the AWS Region, archive name, account ID, and key ID with your values. Omit
--kms-key-arn if you are not using a customer managed AWS KMS key.
PROMPT> aws mailmanager create-archive \ --regioneusc-de-east-1\ --archive-namecompliance-archive\ --retention RetentionPeriod=SEVEN_YEARS \ --kms-key-arn arn:aws-eusc:kms:eusc-de-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab
The response contains the archive ID. Use this ID in Archive actions, searches, and exports.
{ "ArchiveId": "a-1a2b3c4d5e6f" }
For all request members, retention values, and response fields, see CreateArchive in the SES Mail Manager API Reference.
Searching archived email with the AWS CLI
The following diagram shows the search and export job flow. Both operations use the same time range and filter model.
Choosing search filters
Every condition in Include must match. Values within one string
expression are alternatives. If any Unless condition matches, the
message is excluded. CONTAINS performs a case-insensitive substring
match.
The following table maps the available filter attributes to common search purposes.
| Attribute | Use it to search | Example |
|---|---|---|
TO, FROM, CC, or
SUBJECT |
Values in the corresponding message header. | SUBJECT contains invoice. |
ENVELOPE_TO |
Actual SMTP envelope recipients, including a recipient that does
not appear in the To or CC header. |
ENVELOPE_TO contains
accounts-payable@example.com. |
ENVELOPE_FROM |
The SMTP envelope sender. | ENVELOPE_FROM contains
bounces@example.net. |
HAS_ATTACHMENTS |
Messages that have or do not have attachments. | HAS_ATTACHMENTS IS_TRUE. |
Message ID is not an available search attribute. To locate a known message,
narrow the time range with the available attributes and inspect the
MessageId values returned in the result rows.
For the complete filter shape, see ArchiveFilters and ArchiveStringToEvaluate.
Search examples
Find messages from a sender that have attachments
The following command finds up to 100 messages received during a seven-day period. Both Include conditions must match.
PROMPT> aws mailmanager start-archive-search \ --regioneusc-de-east-1\ --archive-ida-1a2b3c4d5e6f\ --from-timestamp 2026-11-16T00:00:00Z \ --to-timestamp 2026-11-23T00:00:00Z \ --max-results 100 \ --filters '{ "Include": [ { "StringExpression": { "Evaluate": {"Attribute": "FROM"}, "Operator": "CONTAINS", "Values": ["billing@example.com"] } }, { "BooleanExpression": { "Evaluate": {"Attribute": "HAS_ATTACHMENTS"}, "Operator": "IS_TRUE" } } ] }'
StartArchiveSearch returns a search ID.
{ "SearchId": "search-0123456789abcdef" }
Find email for either of two SMTP recipients
Use one ENVELOPE_TO expression with two values. A message matches
when either value occurs in an envelope recipient.
{ "Include": [{ "StringExpression": { "Evaluate": {"Attribute": "ENVELOPE_TO"}, "Operator": "CONTAINS", "Values": [ "accounts-payable@example.com", "invoices@example.org" ] } }] }
Find invoice subjects but exclude automatic replies
The Include condition requires invoice. Either Unless value
excludes the message.
{ "Include": [{ "StringExpression": { "Evaluate": {"Attribute": "SUBJECT"}, "Operator": "CONTAINS", "Values": ["invoice"] } }], "Unless": [{ "StringExpression": { "Evaluate": {"Attribute": "SUBJECT"}, "Operator": "CONTAINS", "Values": ["out of office", "automatic reply"] } }] }
To search only by time, omit --filters and provide the required
--from-timestamp, --to-timestamp, and
--max-results values.
Checking search status and retrieving results
Archive searches are asynchronous. Use the search ID with
get-archive-search until Status.State is
COMPLETED.
PROMPT> aws mailmanager get-archive-search \ --regioneusc-de-east-1\ --search-idsearch-0123456789abcdef\ --query Status
A completed search returns a status similar to the following.
{ "SubmissionTimestamp": "2026-11-23T20:10:00Z", "CompletionTimestamp": "2026-11-23T20:10:08Z", "State": "COMPLETED", "ErrorMessage": null }
Valid search states are QUEUED, RUNNING,
COMPLETED, FAILED, and CANCELLED. Calling
GetArchiveSearchResults before completion returns a
ConflictException.
The following command returns selected fields from each result row. Results are ordered from newest to oldest by the time the message entered the archive.
PROMPT> aws mailmanager get-archive-search-results \ --regioneusc-de-east-1\ --search-idsearch-0123456789abcdef\ --query 'Rows[].{ArchivedMessageId:ArchivedMessageId,ReceivedTimestamp:ReceivedTimestamp,From:From,EnvelopeTo:Envelope.To,Subject:Subject,HasAttachments:HasAttachments}'
The response has one object for each matching archived message.
[ { "ArchivedMessageId": "example-archived-message-id", "ReceivedTimestamp": "2026-11-20T15:42:18Z", "From": "Billing <billing@example.com>", "EnvelopeTo": ["accounts-payable@example.com"], "Subject": "November invoice", "HasAttachments": true } ]
For all result fields, see GetArchiveSearchResults.
Downloading or reading one message
Use the ArchivedMessageId from a result row with
get-archive-message. The response contains a temporary download
link for the full message, its SMTP envelope, and source metadata.
PROMPT> aws mailmanager get-archive-message \ --regioneusc-de-east-1\ --archived-message-idexample-archived-message-id
{ "Envelope": { "From": "bounce-handler@example.com", "Helo": "mail.example.com", "To": ["accounts-payable@example.com"] }, "MessageDownloadLink": "https://example.com/temporary-download-link", "Metadata": { "RuleSetId": "rs-0123456789abcdef01234567", "SourceArn": "arn:aws-eusc:ses:eusc-de-east-1:123456789012:mailmanager-rule-set/rs-0123456789abcdef01234567" } }
To return the parsed text and HTML body without attachments, use
get-archive-message-content. For response fields, see GetArchiveMessage and GetArchiveMessageContent.
Exporting archived email with the AWS CLI
Export uses the same Include and Unless filter logic as
search. The destination bucket must be in the same AWS Region as the archive. Configure
the bucket and key policies described in Permission policies for Email archiving before
you start the export.
The following command exports invoice messages while excluding automatic replies. It also requests a metadata JSON object for each exported message.
PROMPT> aws mailmanager start-archive-export \ --regioneusc-de-east-1\ --archive-ida-1a2b3c4d5e6f\ --from-timestamp 2026-11-16T00:00:00Z \ --to-timestamp 2026-11-23T00:00:00Z \ --max-results 1000 \ --export-destination-configuration '{ "S3": { "S3Location": "s3://amzn-s3-demo-bucket/audit/" } }' \ --include-metadata \ --filters '{ "Include": [{ "StringExpression": { "Evaluate": {"Attribute": "SUBJECT"}, "Operator": "CONTAINS", "Values": ["invoice"] } }], "Unless": [{ "StringExpression": { "Evaluate": {"Attribute": "SUBJECT"}, "Operator": "CONTAINS", "Values": ["out of office", "automatic reply"] } }] }'
StartArchiveExport returns an export ID.
{ "ExportId": "export-0123456789abcdef" }
Use the export ID with get-archive-export until
Status.State is COMPLETED.
PROMPT> aws mailmanager get-archive-export \ --regioneusc-de-east-1\ --export-idexport-0123456789abcdef\ --query Status
{ "SubmissionTimestamp": "2026-11-23T20:15:00Z", "CompletionTimestamp": "2026-11-23T20:16:12Z", "State": "COMPLETED", "ErrorMessage": null }
Valid export states are QUEUED, PREPROCESSING,
PROCESSING, COMPLETED, FAILED, and
CANCELLED. A completed export creates a folder named with the export ID
under the requested S3 prefix. The folder contains one .eml object for
each exported message. If IncludeMetadata is true, the folder
also contains a corresponding -meta.json object when metadata is available.
The export uses the destination bucket's encryption configuration.
s3://amzn-s3-demo-bucket/audit/export-0123456789abcdef/ ├── example-message.eml └── example-message-meta.json
For all request and response members, see StartArchiveExport and GetArchiveExport.
Recommendations
-
Use
ENVELOPE_TOwhen you must find the actual SMTP recipient, including a recipient not shown in the message headers. -
Use narrow time ranges and specific Include conditions before increasing
MaxResults. -
Use one common Archive action when multiple later rules route the same email. Repeating Archive actions can create multiple archived copies.
-
Verify customer managed AWS KMS key access before applying a rule or configuration set to production traffic.
-
Run representative searches and exports after setup. Action order and
ActionFailurePolicydo not confirm durable archive storage.
Using email archiving in the Amazon SES console
The Email archiving page in the SES console consists of four interactive tables, Search archive, Search history, Export history, and Manage archives, that you can use to search for email in your archives, export the results, and manage your archives. In the following procedures, instructions are provided for each table.
To use the Email archiving page to search, export, and manage your archives
Sign in to the AWS Management Console and open the Amazon SES console at https://eusc-de-east-1.console.amazonaws-eusc.eu/ses/
. -
In the left navigation panel, choose Email archiving under Mail Manager.
-
The Email archiving page consists of four tables Search archive, Search history, Export history, and Manage archives. For instructions specific to each of these tables, select its corresponding tab below: