mailpit.client.api module

module containing API related

class mailpit.client.api.API(mailpit_url: str, timeout: int | None = None)

Bases: object

class representing the different endpoints of the API

MESSAGES_ENDPOINT = 'api/v1/messages'
MESSAGE_ENDPOINT = 'api/v1/message'
delete_messages(ids: List[str])

send a DELETE request to delete messages

Parameters:

ids – the IDs of the messages to delete; NOTE: passing an empty list will delete all messages

get_message(message_id: str) Message

Send a GET request to get a certain Message by its Message-ID

Parameters:

message_id – The Message-ID to get the message by

get_message_attachment(message_id: str, part_id: str) str

Send a GET request to the message endpoint with querying for the part_id of an attachment

Parameters:
  • message_id – the Message-ID the attachment belongs to

  • part_id – the Part-ID of the attachment to receive

:return the attachment’s data

get_message_headers(message_id: str) Headers

Send a GET request to get a message’s Headers

Parameters:

message_id – The Message-ID to get the headers for

get_messages(limit: int = 50, start: int = 0) Messages

send a GET request in order to retrieve messages

Parameters:
  • limit – limit the returned number of messages

  • start – start at an offset from the beginning

Returns:

the messages returned by mailpit converted into models

put_messages(ids: List[str], key: str, value: Any)

update existing messages; for example pass “Read” as key and True as value to mark messages read

Parameters:
  • ids – the IDs of the messages to update

  • key – the message’s attribute to update

  • value – the value to update the attribute with