The `azure-communication-email` Python client library is part of the Azure Communication Services SDK, enabling developers to integrate email sending capabilities into their applications. It allows sending emails to single or multiple recipients, with support for plain text and HTML content, and attachments. This library helps manage email delivery status and is currently at version 1.1.0, with ongoing development as part of the broader Azure SDK for Python.
pip install azure-communication-emailVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates sending a basic email using a connection string for authentication. For production scenarios, it is recommended to use Azure Active Directory authentication via `DefaultAzureCredential` from the `azure-identity` library. Ensure your Communication Services resource, Email Communication Services resource, and a verified domain are configured in Azure.
Update your code to use `client.begin_send()` which returns a poller. Call `poller.result()` to await the email sending outcome. Adjust property names like `sender` to `senderAddress` and `email` to `address` in your email message construction. Refer to the official changelog for specific version changes.
Configure a custom domain in your Azure Email Communication Services resource. Ensure all required DNS records (SPF, DKIM, DMARC) are correctly set up in your domain provider. For significantly higher volumes, you may need to request a quota increase through Azure support.
Install `azure-identity` (`pip install azure-identity`) and configure your environment for `DefaultAzureCredential` (e.g., Managed Identity on Azure resources, environment variables for local development). Initialize the `EmailClient` with `EmailClient(endpoint=..., credential=DefaultAzureCredential())`.
Ensure you have an Azure Communication Services resource linked to an Azure Email Communication Services resource, which in turn has a verified domain (either Azure Managed or Custom). The `senderAddress` in your email message must match a 'MailFrom' address associated with a verified domain.
Install the package using 'pip install azure-communication-email'.
Ensure that the 'azure' package is installed using 'pip install azure'.
Verify that the correct object type is being used and that it has the expected attributes.
In the Azure portal, navigate to your Azure Communication Services resource, go to the 'Email' section, click 'Domains', and then 'Connect domain' to link your verified email domain to the Communication Service resource. Ensure the data location matches for both resources.
Implement retry logic with exponential backoff in your code, or space out your email sending operations to respect the per-minute and per-hour quotas defined by Azure Communication Services. Consider using a custom domain for higher rate limits.