API

This part of the documentation covers all the interfaces for smtp4dev.

Main Client Object

class smtp4dev.Smtp4Dev(base_url)

API client for SMTP4dev.

get_message(msg_id)

Retrieve a specific message by ID.

Parameters:msg_id – the messages’s pk (a UUID)
Returns:a Message instance
Raises:ApiError
list_messages(unread_only=False)

List all messages in the smtp4dev inbox.

Parameters:unread_only – Only retrieve the unread messages
Returns:a generator of Message items
Raises:ApiError
mark_message_read(msg_id)

Mark a message a read in the inbox.

Parameters:msg_id – the message’s pk (a UUID)
Raises:ApiError

Message Object

class smtp4dev.Message(pk, sender, recipients, received_date, subject, attachment_count, is_unread)

Object representation of an email.

static deserialize(msg, html=None)

Deserialize a dict of data into a Message

Parameters:
  • msg – The message as JSON
  • html – The message’s body as HTML (str)
Returns:

Message

set_body(html)

Set the message’s body

Parameters:html – the html body to set

Exceptions

class smtp4dev.smtp4dev.ApiError

An error during an API call