Sometimes you want to write a dumb email handler.
Good for: low volume, minimal parsing, interacting with legacy email-based systems Bad for: high volume, production use, 100% RFC compliance
Requires Python 3.7+
pip install snails
Usage
import snails
def handle(msg: snails.Message) -> None:
print(f"To: {msg['to']}")
print(f"From: {msg['from']}")
print("Subject: {msg['subject']}")
for p in msg.get_payload():
print(p.get_payload(decode=True))
# manage your own mailbox start/stop
mailbox = snails.Mailbox(handle, "127.0.0.1", 10025)
mailbox.start()
# drop this in __main__, runs and blocks until Ctrl+C
snails.serve(handle, "127.0.0.1", 10025)
Advanced
Not much else to do here. You can return an SMTP status string, but by default if you don’t raise an exception it’ll return “250 OK” and raising an exception returns “500 …”
# calls Mailbox.stop when the python interpreter cleans up
snails.serve(h, "localhost", 25, cleanup_at_exit=True)
# blocks until KeyboardInterrupt
snails.serve(h, "localhost", 25, block=True)
# create a mailbox and start it, and return the object for use
mailbox = snails.serve(h, "localhost", 25, block=False, cleanup_at_exit=True)
... # your code here
mailbox.stop()
# create a mailbox without starting it
mailbox = snails.Mailbox(h, "localhost", 25)
... # your code here
mailbox.start()
... # other code
mailbox.stop()
Metadata
Release files for snails 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snails-1.0.tar.gz | 2.9 kB | Without provenance | Details for snails-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snails-1.0-py3-none-any.whl | Python 3 | none | any | Details for snails-1.0-py3-none-any.whl |
Total release size: 6.7 kB
Release files / snails-1.0.tar.gz
| Download URL | snails-1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eab3d5da549c2896872d3757eada2d456d22a6734b7d4adcf9435c842d356a22
|
|
BLAKE2b-256 checksum How to use checksums |
226a6a987e25faaf94e88725d43d015ea44ff81fd2bf3f31111a9df9a0490d63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / snails-1.0-py3-none-any.whl
| Download URL | snails-1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61f741155338305c17031bc09c51c985a9a20a0301f64405ca4e364481cdc2b3
|
|
BLAKE2b-256 checksum How to use checksums |
708277de965f3d8eb73a3cab9e48a53b2f21b3b2c397c5590d322eec307dd7a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for snails 1.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.