mailpit.client.models module

Definitions of model classes, that wrap Mailpit’s API data-structures. Defined with dataclasses and dataclasses_json, in order to use them as json over the API and be used as objects in the Python domain.

class mailpit.client.models.Attachment(part_id: str, file_name: str, content_type: str, content_id: str, size: int)

Bases: DataClassJsonMixin

Represents an attachment of a Message

content_id: str
content_type: str

Attachment’s MIME content-type

file_name: str

Attachment’s file name

part_id: str

Attachment’s part ID

size: int

Attachment’s size in bytes

class mailpit.client.models.Contact(name: str, address: str)

Bases: object

Represents a mail contact splitting ‘Test User <test@example.com> into its name and address parts

address: str

Contact’s E-Mail address

classmethod from_dict(kvs: dict | list | str | int | float | bool | None, *, infer_missing=False) A
classmethod from_json(s: str | bytes | bytearray, *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
name: str

Contact’s Name

classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
to_dict(encode_json=False) Dict[str, dict | list | str | int | float | bool | None]
to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: int | str | None = None, separators: Tuple[str, str] = None, default: Callable = None, sort_keys: bool = False, **kw) str
class mailpit.client.models.Headers(content_type: list[str], date: list[datetime.date], delivered_to: list[str], from_: list[str], message_id: list[str], additional: CatchAllVar | None)

Bases: object

additional: CatchAllVar | None
content_type: list[str]
dataclass_json_config = {'undefined': Undefined.INCLUDE}
date: list[datetime.date]
delivered_to: list[str]
from_: list[str]
classmethod from_dict(kvs: dict | list | str | int | float | bool | None, *, infer_missing=False) A
classmethod from_json(s: str | bytes | bytearray, *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
message_id: list[str]
classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
to_dict(encode_json=False) Dict[str, dict | list | str | int | float | bool | None]
to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: int | str | None = None, separators: Tuple[str, str] = None, default: Callable = None, sort_keys: bool = False, **kw) str
class mailpit.client.models.Message(id: str, message_id: str, read: bool, from_: Contact | None, to: list[mailpit.client.models.Contact], cc: list[mailpit.client.models.Contact] | None, bcc: list[mailpit.client.models.Contact] | None, subject: str, date: date, text: str | None, html: str | None, size: int, inline: list[mailpit.client.models.Attachment], attachments: list[mailpit.client.models.Attachment])

Bases: DataClassJsonMixin

Represents a message returned by the message-endpoint

attachments: list[mailpit.client.models.Attachment]

Attachments

bcc: list[mailpit.client.models.Contact] | None

Message’s BCC-Header, the list of :Contact:, that the message is blindly coal-copied to

cc: list[mailpit.client.models.Contact] | None

Message’s CC-Header, the list of :Contact: that the message is coal-copied to

date: date

Parsed email local date & time from headers

from_: Contact | None

The :py:class`Contact`: the message is from

html: str | None

HTML MIME part (if exists)

id: str

Message’s database ID, of Mailpit’s message-database

inline: list[mailpit.client.models.Attachment]

Inline Attachments

message_id: str

Message’s RFC-5322 message-id

read: bool

Always true (message marked read on open)

size: int

Total size of raw email in bytes

subject: str

Message’s subject

text: str | None

Plain text MIME part of the email

to: list[mailpit.client.models.Contact]

Message’s To-Header, the list of :Contact: the message is addressed to

class mailpit.client.models.MessageSummary(id: str, message_id: str, read: bool, from_: Contact | None, to: list[mailpit.client.models.Contact], cc: list[mailpit.client.models.Contact] | None, bcc: list[mailpit.client.models.Contact], subject: str, created: date, size: int, attachments: int)

Bases: DataClassJsonMixin

class representing a single message that has been returned by the messages endpoint

attachments: int
bcc: list[mailpit.client.models.Contact]
cc: list[mailpit.client.models.Contact] | None
created: date

Parsed email local date & time from headers

from_: Contact | None
id: str
message_id: str
read: bool

always true (message marked read on open)

size: int

Total size of raw email

subject: str

Message subject

to: list[mailpit.client.models.Contact]
class mailpit.client.models.Messages(total: int, unread: int, count: int, start: int, messages: list[mailpit.client.models.MessageSummary])

Bases: DataClassJsonMixin

class representing the returns of the messages endpoint

count: int

Number of messages returned in request

messages: list[mailpit.client.models.MessageSummary]
start: int

The offset (default=0) for pagination

total: int

Total messages in mailbox

unread: int

Total unread messages in mailbox

mailpit.client.models.datelist_decoder(decodes: Iterable[str]) list[datetime.datetime]
mailpit.client.models.datelist_encoder(encodes: Iterable[datetime]) list[str]
mailpit.client.models.datetime_decoder(isoformat: str) datetime

replaces golang isoformat with Python parsable isoformat and decodes it to datetime.datetime

mailpit.client.models.millis_to_3_digit(isoformat: str) str

replaces milliseconds with three-digits long value using zero padding before

mailpit.client.models.zulu_to_utc_shift(isoformat: str) str

replaces ‘Z’ with ‘+00:00’ for UTC