Skip to main content

API-client for https://github.com/axllent/mailpit written in Python

Authors:

Lars Liedtke <corvan@gmx.de>

Version:

1.0.0

Go to the documentation

Motivation

For work, I thought about introducing integration testing. We are working with Odoo and I wanted to test if e-mails created by Odoo really were sent. I remembered mailhog, which I discovered to be abandoned. Searching for an alternative, I found Mailpit - for which I decided to write an API-client in my free time.

Install

If you want to use the library with unittest:

pip install mailpit-api-client

If you want to use the library with pytest:

pip install mailpit-api-client[pytest]

Usage

this library - as is Mailpit - is mostly meant for testing. Giving the url of Mailpit to a tool to send e-mail messages to and then use this client to check on the API if the mail was sent.

Client

The client itself consists of the class API in mailpit/client/api.py, that offers methods, which query the API-Endpoints and are named respectively. To use this class, simply try something like this. You have to have Mailpit running on localhost for this [1] .

import mailpit.client.api
api = mailpit.client.api.API("localhost:8025")
messages = api.get_messages()

Additionally, there are some model-classes that wrap the API’s responses. For example with

messages = api.get_messages()

messages will be an instance of mailpit.client.models.Messages , which you can find in link:mailpit/client/models/messages.py[mailpit/client/models.py]. + The model-classes’ attributes are named the same as Mailpit’s responses, as documented in the API’s README.md, but as is convention in Python in Snakecase.

For examples have a look at the link:tests[tests]

Testing

To make testing easier there are test-helpers inside the mailpit.testing package.

unittest

In order to provide some convenience a test-case class has been created with the name EMailTestCase deriving from unittest.TestCase, which is meant to be inherited from, as you would do from TestCase:

from mailpit.testing.unittest import EMailTestCase

class MyTest(EMailTestCase):

     def test_sending_email():
        ...

The class adds a few methods and attributes, so that you are able to assert, if your message has been sent, or if two messages are equal.

pytest

tbd

Metadata

Release files for mailpit-api-client 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mailpit-api-client 1.0.0
File Size Uploaded Provenance Actions
mailpit-api-client-1.0.0.tar.gz 16.0 kB Without provenance Details for mailpit-api-client-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mailpit-api-client 1.0.0
File Interpreter ABI Platform Actions
mailpit_api_client-1.0.0-py3-none-any.whl Python 3 none any Details for mailpit_api_client-1.0.0-py3-none-any.whl

Total release size: 31.0 kB

Release files / mailpit-api-client-1.0.0.tar.gz

Download URL mailpit-api-client-1.0.0.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8e095a0c95860f198ee4d7702db516ebbfcebe6953dd50b1b0f62323915c815a
BLAKE2b-256 checksum
How to use checksums
b6e6f88d95c0b20165f24c925b8443337667e54ba1eef2a21eacbb8b598a4910
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Release files / mailpit_api_client-1.0.0-py3-none-any.whl

Download URL mailpit_api_client-1.0.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab6e0cf69c9516db75e9a428305ede5de7bfb0fcd0a76149509db7b0796eedba
BLAKE2b-256 checksum
How to use checksums
3d2e9f2504f7ba0772226b4f756a035f34e833cd3628d56ceff7927ca1baa73e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.1 CPython/3.11.4

Security for mailpit-api-client 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page