Skip to main content

Localmail

For local people.

Localmail is an SMTP and IMAP server that stores all messages into a single in-memory mailbox. It is designed to be used to speed up running test suites on systems that send email, such as new account sign up emails with confirmation codes. It can also be used to test SMTP/IMAP client code.

Features:

  • Fast and robust IMAP/SMTP implementations, including multipart messages and unicode support.

  • Includes simple HTTP interface for reading messages, which is useful for checking html emails.

  • Compatible with python’s stdlib client, plus clients like mutt and thunderbird.

  • Authentication is supported but completely ignored, all message go in single mailbox.

  • Messages not persisted by default, and will be lost on shutdown. Optionally, you can log messages to disk in mbox format.

Missing features/TODO:

  • SSL support

WARNING: not a real SMTP/IMAP server - not for production usage.

Running localmail

twistd localmail

This will run localmail in the background, SMTP on port 2025 and IMAP on 2143, It will log to a file ./twistd.log. Use the -n option if you want to run in the foreground, like so.

twistd -n localmail

You can pass in arguments to control parameters.

twistd localmail --imap <port> --smtp <port> --http <port> --file localmail.mbox

You can have localmail use random ports if you like. The port numbers will be logged. TODO: enable writing random port numbers to a file.

twisted -n localmail --random

Embedding

If you want to embed localmail in another non-twisted program, such as test runner, do the following.

import threading
import localmail

thread = threading.Thread(
   target=localmail.run,
   args=(2025, 2143, 8880, 'localmail.mbox')
)
thread.start()

...

localmail.shutdown_thread(thread)

This will run the twisted reactor in a separate thread, and shut it down on exit.

If you want to use random ports, you can pass a callback that will have the ports the service is listening on.

import threading
import localmail

def report(smtp, imap, http):
    """do stuff with ports"""

thread = threading.Thread(
   target=localmail.run,
   args=(0, 0, 0, None, report)
)
thread.start()

History

0.4 (2015-08-14)

  • support for using random port numbers

  • available as a universal wheel, general packaging improvements

  • Simple HTTP interface for browsing mail (requires jinja2)

  • Support writing to mbox file

  • Fixed date to work with mutt, example muttrc included in package.

0.3 (2013-05-24)

  • Multipart message support [via Ed Jannoo]

  • IMAP UID support

  • Support python 2.6, 2.7 and pypy, tested via tox

0.2 (2012-11-13)

  • Initial public release

  • Basic SMTP/IMAP server

Credits

“localmail” is written and maintained by Simon Davy

Contributors

The following people contributed directly or indirectly to this project:

  • Ed Jannoo <ed@azordi.com>

Metadata

Release files for localmail 0.5.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 localmail 0.5.0
File Size Uploaded
localmail-0.5.0.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for localmail 0.5.0
File Interpreter ABI Platform
localmail-0.5.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 39.7 kB

Release files / localmail-0.5.0.tar.gz

Download URL localmail-0.5.0.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
63ad0219e9772a39970682a126ccb34ae8760983b8a90d7ccf877ba97d27d424
BLAKE2b-256 checksum
How to use checksums
947f263eea21591438afe38bf0ae77054e06591b61b56e94865aeb7d61e179c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / localmail-0.5.0-py2.py3-none-any.whl

Download URL localmail-0.5.0-py2.py3-none-any.whl
Size 13.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
7050ac0319d6e3126ebf3a49de67e5a1115d9809eb7efd84886de3ce7d35f359
BLAKE2b-256 checksum
How to use checksums
8681072be46d0327bcc050c99fb2b3a8cfa3bf6e2706c865a821734e0d7bea3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3

1 release file

0.3.0

1 release file

0.2

1 release file

0.1

1 release file

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