# Aws Ses

## Description

AWS SES is a transactional email provider for AWS environments. Your application code depends on `IFlexEmailProvider`.

## Configuration in DI

Register only the provider.

```csharp
services.AddFlexAwsSesEmailProvider(configuration);
```

## appsettings.json

Configuration is read from `FlexBase:Providers:Email:AwsSes`.

```json
{
  "FlexBase": {
    "Providers": {
      "Email": {
        "AwsSes": {
          "AccessKeyId": "<store-in-secrets>",
          "SecretAccessKey": "<store-in-secrets>",
          "Region": "us-east-1",
          "DefaultFromEmail": "noreply@company.com",
          "DefaultFromName": "Company",
          "ConfigurationSetName": null,
          "MaxRetries": 3,
          "Timeout": "00:00:30"
        }
      }
    }
  }
}
```

## Examples (template-based)

This mirrors the generated PostBus handler shape (you do not register the handler manually).

```csharp
using Microsoft.Extensions.Logging;
using Sumeru.Flex;
using System.Threading.Tasks;

namespace {YourApplication}.PostBusHandlers.Email;

public partial class SendAwsSesEmailHandler : ISendAwsSesEmailHandler
{
	protected string EventCondition = string.Empty;

	protected readonly ILogger<SendAwsSesEmailHandler> _logger;
	protected readonly IFlexHost _flexHost;
	protected readonly IFlexEmailProvider _emailProvider;

	protected FlexAppContextBridge? _flexAppContext;

	public SendAwsSesEmailHandler(
		ILogger<SendAwsSesEmailHandler> logger,
		IFlexHost flexHost,
		IFlexEmailProvider emailProvider)
	{
		_logger = logger;
		_flexHost = flexHost;
		_emailProvider = emailProvider;
	}

	public virtual async Task Execute(SendAwsSesEmailCommand cmd, IFlexServiceBusContext serviceBusContext)
	{
		_flexAppContext = cmd.Dto.GetAppContext();  //do not remove this line

		await _emailProvider.SendAsync(
			to: cmd.Dto.To,
			subject: cmd.Dto.Subject,
			body: cmd.Dto.Body,
			from: cmd.Dto.From);

		await this.Fire(EventCondition, serviceBusContext);
	}
}
```

## Provider considerations

* Ensure SES sender identities/domains are verified.
* Use IAM least-privilege for SES send permissions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.flexbase.in/data-and-providers/providers/e-mail/aws-ses.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
