Skip to content

âš¡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 the msgspec 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 #

AsyncMail(account_token: t.Optional[Token] = None)

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.

TYPE: t.Optional[Token] DEFAULT: None

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_me() -> t.Optional[Account]

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_domain(domain_id: str) -> t.Optional[Domain]

Get a specific domain with ID.

PARAMETER DESCRIPTION
domain_id

The ID of the domain to get.

TYPE: str

RETURNS DESCRIPTION
Optional[Domain]

The domain with the ID provided. If not found, returns None.

get_account async #

get_account(account_id: str) -> t.Optional[Account]

Get an accnount by it's ID.

PARAMETER DESCRIPTION
account_id

The ID of the account to get.

TYPE: str

RETURNS DESCRIPTION
Optional[Account]

The account with the ID provided. If not found, returns None.

create_account async #

create_account(
    address: str, password: str
) -> t.Optional[Account]

Create an account.

PARAMETER DESCRIPTION
address

The email address of the new account.

TYPE: str

password

The password for the new account.

TYPE: str

RETURNS DESCRIPTION
Optional[Account]

The newly created account object if successful, None otherwise.

delete_account async #

delete_account(account_id: t.Optional[str] = None) -> None

Delete an account by it's ID.

PARAMETER DESCRIPTION
account_id

The ID of the account to delete. If not provided, the account token will be used.

TYPE: t.Optional[str] DEFAULT: None

RETURNS DESCRIPTION
None

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: int DEFAULT: 1

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 #

get_message(message_id: str) -> t.Optional[Message]

Get a specific message with ID.

PARAMETER DESCRIPTION
message_id

The ID of the message to get.

TYPE: str

RETURNS DESCRIPTION
Optional[Message]

The message with the ID provided. If not found, returns None.

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: str

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: str

RETURNS DESCRIPTION
None

get_source async #

get_source(source_id: str) -> t.Optional[Source]

Get source by the source ID.

PARAMETER DESCRIPTION
source_id

The ID of the source to get.

TYPE: str

RETURNS DESCRIPTION
Optional[Source]

The source with the ID provided. If not found, returns None.

close async #

close()

Close the client.