Mypy Boto3 SESV2

1.42.63 · active · verified Sat Apr 11

mypy-boto3-sesv2 provides comprehensive type annotations for the AWS boto3 SESV2 (Simple Email Service v2) client, paginators, and waiters. It allows developers to leverage static type checking with Mypy for their boto3 code, improving code quality and catching potential errors early. The library is updated frequently, often alongside new boto3/botocore releases and builder improvements, ensuring up-to-date and accurate type definitions. Current version: 1.42.63.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an SESV2 client with `mypy-boto3-sesv2` type annotations and perform a `send_email` operation using type-checked arguments. It also shows how to use a paginator for listing resources. Remember to replace placeholder email addresses and ensure your AWS credentials and region are configured.

import boto3
from mypy_boto3_sesv2.client import SESV2Client
from mypy_boto3_sesv2.type_defs import SendEmailRequestRequestTypeDef
import os

# Initialize a boto3 client with type hints
client: SESV2Client = boto3.client(
    "sesv2",
    region_name=os.environ.get('AWS_REGION', 'us-east-1')
)

# Example: Sending a simple email with type-checked arguments
request_params: SendEmailRequestRequestTypeDef = {
    "FromEmailAddress": "sender@example.com", # Replace with a verified sender
    "Destination": {
        "ToAddresses": [
            "recipient@example.com" # Replace with a recipient
        ]
    },
    "Content": {
        "Simple": {
            "Subject": {"Data": "Hello from mypy-boto3-sesv2!"},
            "Body": {"Text": {"Data": "This is a test email sent with SESv2."}}
        }
    }
}

try:
    response = client.send_email(**request_params)
    print(f"Email sent successfully! Message ID: {response['MessageId']}")
except Exception as e:
    print(f"Error sending email: {e}")

# Example: Listing configuration sets using a paginator
paginator = client.get_paginator("list_configuration_sets")
for page in paginator.paginate():
    for config_set in page.get("ConfigurationSets", []):
        print(f"Configuration Set: {config_set['ConfigurationSetName']}")

view raw JSON →