Tencent Cloud SES SDK for Python

raw JSON →
3.1.85 verified Sat May 09 auth: no python

Official Tencent Cloud SDK for Simple Email Service (SES). Version 3.1.85. Part of the Tencent Cloud Python SDK with product-specific packages; released frequently alongside the main SDK. Requires a Tencent Cloud secret ID and key for authentication.

pip install tencentcloud-sdk-python-ses
error ModuleNotFoundError: No module named 'tencentcloud.ses.v20201002'
cause Installing the common package but forgetting the product-specific package.
fix
pip install tencentcloud-sdk-python-ses
error AttributeError: module 'tencentcloud.ses' has no attribute 'ses_client'
cause Importing from the non-versioned module.
fix
Use: from tencentcloud.ses.v20201002 import ses_client
error TencentCloudSDKException: [InvalidParameter] InvalidParameterValue
cause Required fields missing or incorrect in the request model (e.g., no Subject or Destination).
fix
Ensure all mandatory fields are set: FromEmailAddress, Destination, Subject, and either Simple or Template.
gotcha All requests require an API version suffix in the import path (v20201002). Using tencentcloud.ses without the version will cause ModuleNotFoundError.
fix Use from tencentcloud.ses.v20201002 import ses_client, models
deprecated The SDK old instance-based client (e.g., TencentCloudAPI) is deprecated. Use the request-style (client + request object) pattern.
fix Instantiate client with SesClient(cred, region) and call methods with request objects.
gotcha Region must be explicitly set, even if using default. Some users omit region and get connection errors.
fix Always pass a region string (e.g., 'ap-guangzhou') to the client constructor.

Send a simple email using SES client with secret id/key from environment variables.

import os
from tencentcloud.common import credential
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ses.v20201002 import ses_client, models

try:
    cred = credential.Credential(
        os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
        os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
    )
    client = ses_client.SesClient(cred, 'ap-guangzhou')
    req = models.SendEmailRequest()
    req.FromEmailAddress = 'sender@example.com'
    req.Destination = ['recipient@example.com']
    req.Subject = 'Test'
    req.Simple = models.Simple()
    req.Simple.Subject = 'Test'
    req.Simple.HtmlBody = '<p>Hello</p>'
    resp = client.SendEmail(req)
    print(resp.RequestId)
except TencentCloudSDKException as err:
    print(err)