Skip to content

Async support for MailerSend Python SDK (httpx / aiohttp) #200

@hfbmb

Description

@hfbmb

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Yes.
Currently the mailersend-python SDK provides only a synchronous API.
This becomes problematic when using modern async Python frameworks such as FastAPI, Starlette, or any asyncio-based application.
In async applications, calling synchronous I/O (like the current MailerSend client) blocks the event loop. As a result:
the request handler cannot release control back to the event loop
concurrent requests are delayed
application throughput decreases
This forces developers to either:
run the email sending code inside run_in_threadpool
use BackgroundTasks
or completely bypass the SDK and call the MailerSend API directly using httpx.AsyncClient
All of these approaches defeat the purpose of having an official SDK.

Describe the solution you'd like
A clear and concise description of what you want to happen.

It would be extremely useful to have native async support in the Python SDK.
For example, an async client built on top of:
httpx.AsyncClient
or
aiohttp
Example API:
from mailersend_async import AsyncMailerSendClient

client = AsyncMailerSendClient(api_key="API_KEY")

await client.emails.send(email=email_data)
This would allow the SDK to be used efficiently in async frameworks like:
FastAPI
Starlette
Quart
Async workers (Celery with asyncio, Arq, etc.)

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Currently the only alternatives are:

Running the synchronous SDK in a thread pool
await run_in_threadpool(client.emails.send, email)

However this introduces:
unnecessary thread overhead
context switching
reduced performance under load

Sending requests manually using httpx
Example:
async with httpx.AsyncClient() as client:
await client.post(
"https://api.mailersend.com/v1/email",
headers={"Authorization": f"Bearer {API_KEY}"},
json=payload
)

But this means:
reimplementing parts of the SDK
losing built-in abstractions provided by the library

Additional context
Add any other context or screenshots about the feature request here.

Async support is becoming increasingly important in the Python ecosystem.
Many modern production backends are now built using async-first frameworks, especially FastAPI.
Without async support, developers are forced to either:
block the event loop
introduce thread pools
or bypass the SDK completely
Providing an async implementation would significantly improve the developer experience and make the SDK more suitable for modern Python applications.
I would be happy to help test or contribute if such a feature is planned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions