Skip to main content

Simple SMTP server for testing mailing code.

Project description

# MailMitt

MailMitt is a tool for performing regression testing on email delivery code.
It allows applications to send emails to an SMTP server without actual emails
being delivered to anyone.

It also provides both a web interface and a RESTful JSON API for reviewing the
content of the emails that you send.

Nothing is actually delivered, and any emails that MailMitt receives are just
stored in memory.

It is inspired by, although it is
re-written from the ground up using an asyncio-based event loop rather than gevent.

Because of this, it only runs on Python 3.5 and above, whereas MailDump only runs on
Python 2.

## Installation

pip3 install mailmitt

## Usage

`mailmitt --help`

produces a list of available command line arguments.

By default mailmitt runs its webserver on port
1080 and its SMTP server on port 1025 (both only available via localhost). If
you want to access it from another machine, use something like this:

`mailmitt --http-ip --smtp-ip`

## API

`GET http://localhost:1080/messages`

* Gets all emails, including their content, as a JSON tree.

`GET http://localhost:1080/messages/0.source`

* Gets the source for the first email. Replace `0` with the index of the email you wish to retrieve

`GET http://localhost:1080/messages/0.plain`

* Gets the plaintext version of the first email.

`GET http://localhost:1080/messages/0.html`

* Gets the HTML version of the first email if it exists.

`GET http://localhost:1080/messages/0.json`

* Gets a JSON representation of the first email.

`DELETE http://localhost:1080/messages`

* Deletes all emails from memory

## Sample Usage

Run this in one terminal:

And then in a python3 session:

import requests
import smtplib
from email.message import EmailMessage

message = EmailMessage()
message['Subject'] = "Sample Subject"
message['To'] = ""
message['From'] = ""

This is a sample email

<p>This is a sample email</p>
""", subtype='html')

with smtplib.SMTP('localhost',port=1025) as smtp:


Although this example is in Python, MailMitt can be accessed from SMTP client
libraries in any language.

This is a sample email

## Webserver
You will also be able to review your emails at http://localhost:1080/

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailmitt-0.0.4.tar.gz (10.8 kB view hashes)

Uploaded source

Built Distribution

mailmitt-0.0.4-py3-none-any.whl (14.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page