âš¡Async Mail#
Client used for asynchronous operations using the aiohttp
client library. This would work in sessions.
Warn
After you're finished with a session. Do not forget to close the session yourself by calling close()
. This will close the session and it won't eat memory any further.
🚀 X-Client#
- This module provides an asyncio-based client for the Mail.TM API.
- It allows to create, delete, and manage accounts, messages, and sources. As well as retrieve information about domains.
- The API is based on the
aiohttp
library and uses themsgspec
library to decode the JSON responses from the API into Python objects. - The client is easy to use and is designed to be used in an asyncio-based application.
- The API is documented at Mail.tm Documentation
You don't have to worry about:
- The client automatically handles errors and exceptions, so you don't have to.
- The client also handles rate limits, so you don't have to.
You do have to worry about:
- The client does not handle connection limits, so you might have to.
- The client does not handle SSL verification, so you might have to.
AsyncMail
#
Asynchronous based client handler for the SDK/library.
PARAMETER | DESCRIPTION |
---|---|
account_token |
The account token to use for authentication. If not provided, the client will not be authenticated. |
Examples:
import asyncio
from mailtm import AsyncMail
async def main():
async with AsyncMail() as client:
account = await client.get_me()
print(account)
asyncio.run(main())
get_me
async
#
Get the user associated with the account token provided to create a session.
RETURNS | DESCRIPTION |
---|---|
Optional[Account]
|
The user associated with the account token provided to create a session. If not authenticated, returns None. |
get_domains
async
#
get_domains() -> t.Optional[DomainPageView]
Get a page view of domains available under the account token provided to create a session.
RETURNS | DESCRIPTION |
---|---|
Optional[DomainPageView]
|
A page view of domains available under the account token provided to create a session. If not authenticated, returns None. |
get_domain
async
#
get_account
async
#
create_account
async
#
delete_account
async
#
get_messages
async
#
get_messages(page: int = 1) -> t.Optional[MessagePageView]
Get a page view of messages available under the account token provided to create a session.
PARAMETER | DESCRIPTION |
---|---|
page |
The page number to get. Defaults to 1.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[MessagePageView]
|
A page view of messages available under the account token provided to create a session. If not authenticated, returns None. |
get_message
async
#
delete_message
async
#
delete_message(message_id: str) -> None
Delete a specific message with ID.
PARAMETER | DESCRIPTION |
---|---|
message_id |
The ID of the message to delete.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
|
mark_as_seen
async
#
mark_as_seen(message_id: str) -> None
Flag a message as seen.
PARAMETER | DESCRIPTION |
---|---|
message_id |
The ID of the message to mark as seen.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
|