Skip to main content

larzemail

Build, parse and send MIME email the easy way — zero dependencies.

Python's email package is powerful and famously awkward. larzemail wraps it in a one-object API: set a subject, text and/or HTML body, and attachments, then get valid MIME bytes — or parse a raw message straight back into a plain object. It also sends over SMTP, with an injectable connection so your sending code stays unit-testable.

Install

pip install larzemail

Use

from larzemail import Email

msg = (Email(subject="Your receipt", from_addr="billing@acme.com",
             to=["ada@example.com"], cc="ops@acme.com")
       .body(text="Thanks for your order.",
             html="<h1>Thanks!</h1><p>Your order shipped.</p>")
       .attach("receipt.pdf", pdf_bytes, "application/pdf"))

raw = msg.as_bytes()                 # valid MIME, ready to send
msg.send(host="smtp.acme.com", port=587, username="u", password="p", use_tls=True)

parsed = Email.parse(raw)            # -> ParsedEmail
parsed.subject, parsed.text, parsed.html, parsed.attachments

Testable sending

msg.send(connection=fake_smtp)       # any object with send_message(msg, from_addr, to_addrs)

Tests

python -m unittest discover -s tests -v   # 9 tests

The Larz stack

One of 60+ pure-Python, zero-dependency libraries at github.com/larz-scripter. Pairs with larzpdf (attach a generated invoice) and larzical (attach a calendar invite).

License

MIT (c) larz-scripter

Download files

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

Source Distribution

larzemail-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larzemail-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file larzemail-0.1.0.tar.gz.

File metadata

  • Download URL: larzemail-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzemail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df104df2b4ac83721b26c956f4f153573c5b0844c103a4d6a6f1ff9e8644ee2c
MD5 0fd1ca58cde0b692768b612ca8e400ef
BLAKE2b-256 b45d8db0bb07248a75d88042a312e350916e1fafe3ce7fab4f0fa9909decc1ad

See more details on using hashes here.

File details

Details for the file larzemail-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: larzemail-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for larzemail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cdcf3eab4075c291d14a43d5e4cc90b5f9939cee85ba86f3e72450898fba713
MD5 189eee64597f0c68bad8dbc75585e387
BLAKE2b-256 eda059b7e3019b11503a97ebf13a8774006c40cc66163370c2a2909630438c41

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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