Skip to main content

Open-source email automation and delivery engine

Project description

๐Ÿ“ฌ OpenMailer

OpenMailer is a free, open-source Python email delivery framework.

Send transactional or bulk email with your own SMTP server โ€” Gmail, Outlook, AWS SES, Postfix, or any custom SMTP. No need for SendGrid, Mailgun, or other paid services.


๐Ÿš€ Why OpenMailer?

Problem How OpenMailer Solves It
๐Ÿ’ฐ Expensive APIs Uses your own SMTP โ€” no vendor fees
๐Ÿ”’ Vendor lock-in 100% self-hosted, open-source, and extensible
๐Ÿคฏ Complex APIs Developer-first design with both CLI & Python SDK
๐Ÿ” No visibility Transparent retry queue, terminal UI, logging, reports

๐Ÿ”ง Key Features

  • โœ… HTML email templating ({{name}}, {{link}}, etc.)
  • โœ… Multi-backend SMTP routing & failover
  • โœ… Attachments (PDFs, ZIPs, images)
  • โœ… Scheduled send (--schedule)
  • โœ… Retry queue with live retry command (--retry)
  • โœ… Priority queuing (--priority)
  • โœ… Open tracking with tracking pixel
  • โœ… Rate limiting & throttling
  • โœ… Local testing (--dry-run โ†’ saves to ./outbox)
  • โœ… CLI (opmctl) and Python SDK
  • โœ… Bulk sending with real-time terminal table
  • โœ… Feedback reports for bulk send
  • โœ… Health check & analytics module
  • โœ… Plugin-ready architecture

๐Ÿงฑ Project Structure

openmailer/
โ”œโ”€โ”€ client.py              # Core email client logic
โ”œโ”€โ”€ smtp_engine.py         # Low-level SMTP sending
โ”œโ”€โ”€ template_engine.py     # Jinja2-based rendering
โ”œโ”€โ”€ queue_manager.py       # Handles retries & delays
โ”œโ”€โ”€ rate_limiter.py        # Enforces send rate control
โ”œโ”€โ”€ logger.py              # Log storage (JSON + terminal)
โ”œโ”€โ”€ secrets.py             # Secure credential loading
โ”œโ”€โ”€ localmode.py           # --dry-run support
โ”œโ”€โ”€ analytics.py           # Tracks send metrics
โ”œโ”€โ”€ config.py              # Default + override configs
โ”œโ”€โ”€ health_monitor.py      # SMTP health & uptime logic

cli/
โ””โ”€โ”€ main.py                # CLI entrypoint (`opmcli`)

๐Ÿ“ฆ Installation

git clone https://github.com/Devops-Bot-Official/OpenMailer.git
cd openmailer
python setup.py install

Then:

chmod +x cli/main.py
ln -s $(pwd)/cli/main.py /usr/local/bin/opmctl

๐Ÿ–ฅ๏ธ OpenMailer CLI

OpenMailer CLI (opmcli) is a full-featured command-line interface for managing email delivery using the OpenMailer engine.

โš™๏ธ Single Send

opmctl --to user@example.com \
       --subject "Hello {{name}}" \
       --template templates/welcome.html \
       --context '{"name": "Alice"}' \
       --attachment invoice.pdf \
       --schedule "2025-07-01 09:00" \
       --priority high \
       --track-open \
       --report

๐Ÿ“ฌ Bulk Email (via CSV)

opmctl bulk --csv contacts.csv --template templates/newsletter.html --report

CSV Format:

email,subject,name,link
alice@example.com,Welcome,Alice,https://example.com/welcome
bob@example.com,News,Bob,https://example.com/update

๐Ÿงช Testing Mode

opmctl --to test@example.com --template templates/test.html --dry-run

Saves the output to ./outbox/ instead of sending real email.

โœ… Test Results

================================================================== test session starts ===================================================================
platform linux -- Python 3.12.3, pytest-8.4.1, pluggy-1.6.0
rootdir: /home/ubuntu/Project/project
configfile: pyproject.toml
plugins: cov-6.2.1
collected 20 items                                                                                                                                       

tests/test_analytics.py .                                                                                                                          [  5%]
tests/test_client.py .........                                                                                                                     [ 50%]
tests/test_client_send_email.py .                                                                                                                  [ 55%]
tests/test_health_monitor.py .                                                                                                                     [ 60%]
tests/test_localmode.py .                                                                                                                          [ 65%]
tests/test_logger.py .                                                                                                                             [ 70%]
tests/test_rate_limiter.py .                                                                                                                       [ 75%]
tests/test_secrets.py ...                                                                                                                          [ 90%]
tests/test_template_engine.py ..                                                                                                                   [100%]

==================================================================== warnings summary ====================================================================
tests/test_client.py::test_queue_and_retry
  /home/ubuntu/Project/project/openmailer/queue_manager.py:20: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    job["queued_at"] = datetime.utcnow().isoformat()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
===================================================================== tests coverage =====================================================================
____________________________________________________ coverage: platform linux, python 3.12.3-final-0 _____________________________________________________

Name                            Stmts   Miss  Cover   Missing
-------------------------------------------------------------
openmailer/__init__.py              1      0   100%
openmailer/analytics.py             9      0   100%
openmailer/client.py              120     33    72%   32-35, 49, 51, 84-94, 112-149, 171-172, 176-179, 223-225
openmailer/config.py                2      2     0%   1-3
openmailer/health_monitor.py       10      0   100%
openmailer/localmode.py             8      0   100%
openmailer/logger.py                5      0   100%
openmailer/message_builder.py      17      0   100%
openmailer/queue_manager.py        27      2    93%   10, 33
openmailer/rate_limiter.py         24      2    92%   24, 28
openmailer/secrets.py              48     10    79%   40-44, 51, 54, 61-62, 65
openmailer/smtp_engine.py           8      6    25%   4-9
openmailer/template_engine.py       3      0   100%
-------------------------------------------------------------
TOTAL                             282     55    80%
============================================================= 20 passed, 1 warning in 6.90s ==============================================================

๐Ÿช„ CLI Options

Flag Description
--to Email recipient address
--subject Subject line of the email
--template HTML file to use as email body
--context JSON dict injected into the template ({{name}})
--attachment One or more attachments (PDF, ZIP, etc.)
--schedule Future datetime for scheduled send (UTC/local)
--priority Email priority: high, normal, low
--track-open Add tracking pixel to monitor opens
--dry-run Save email as file without actually sending
--report Sends delivery report to sender
--retry Retry all failed or queued emails
bulk Use for bulk email campaign via CSV

๐Ÿ“Š Real-Time Table (Bulk Send)

During bulk send, the CLI displays a live table with email progress:

๐Ÿ“ฌ Bulk Email Progress
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Recipient         โ”ƒ Subject       โ”ƒ Status   โ”ƒ Error                โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ alice@example.com โ”‚ Welcome       โ”‚ โœ… Sent   โ”‚                      โ”‚
โ”‚ bob@example.com   โ”‚ Update        โ”‚ โŒ Failed โ”‚ SMTP connect timeout โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿง‘โ€๐Ÿ’ป Python SDK (Library Usage)

from openmailer import OpenMailerClient

client = OpenMailerClient()

client.send_email(
    to="user@example.com",
    subject="Hello {{name}}",
    html_body="<h1>Hello {{name}}</h1>",
    context={"name": "Bob"},
    attachments=["contract.pdf"]
)

Bulk Programmatic Send

report = client.send_bulk(
    recipients=["a@example.com", "b@example.com"],
    subject="Notice",
    html_body="<p>Hi {{name}}</p>",
    context_fn=lambda to: {"name": to.split("@")[0]}
)
client.feedback_to_sender("admin@example.com", report)

๐Ÿงช Retry

Failed deliveries are automatically stored in the retry queue.

To resend:

opmctl --retry

๐Ÿง  Developer Notes

  • Retry queue is file-based, future versions will support Redis or DB
  • Open tracking uses an invisible pixel hit
  • Supports Gmail, Outlook, AWS SES, and more (with auth configs)
  • Feedback system reports how many sent/failed, per recipient
  • CLI uses rich for real-time terminal rendering
  • Designed to plug into CI/CD or automation pipelines

๐Ÿ’ก Use Cases

  • Transactional messages (signup, password reset)
  • System alerts and DevOps monitoring
  • Custom marketing newsletters
  • Embedded email engine in SaaS products
  • Developer testing in local/airgapped environments

๐Ÿ›ฃ Roadmap

  • โœ… Full SMTP support
  • โœ… Retry and feedback system
  • โœ… Bulk send and tracking
  • โœ… Live table output for progress
  • ๐Ÿ”œ REST API server mode
  • ๐Ÿ”œ OAuth2 SMTP (Google, Outlook)
  • ๐Ÿ”œ Admin dashboard UI
  • ๐Ÿ”œ Docker image with SMTP + UI
  • ๐Ÿ”œ Plugin SDK for custom auth/rules

๐Ÿค Contributing

We welcome contributions from Pythonistas and email nerds.

git clone https://github.com/Devops-Bot-Official/OpenMailer.git
cd openmailer
python setup.py install

Contributor Guidelines

  • Engine logic goes in openmailer/
  • CLI logic lives in cli/
  • Avoid hardcoding โ€” use config/environment
  • Document new features in README
  • PRs should pass basic tests and lint

๐Ÿ“œ License

MIT License โ€” use it freely in personal and commercial projects.


โค๏ธ About

OpenMailer is built by and for developers who believe in freedom, transparency, and open infrastructure. No API limits. No billing traps. Just email that works.

Made with ๐Ÿ Python. Powered by SMTP.

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

openmailer-0.1.2.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

openmailer-0.1.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file openmailer-0.1.2.tar.gz.

File metadata

  • Download URL: openmailer-0.1.2.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for openmailer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c66f8204dfcf20b20f230bdee0c372c683a056882168eabcb8394617a85c9791
MD5 4e287e9983f9f140aab935d3cc473b9d
BLAKE2b-256 77872acfe9e79c5a0e33575542ae93bec44bafb4c9f05ba3089882a6702465a4

See more details on using hashes here.

File details

Details for the file openmailer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: openmailer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for openmailer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4954bac35362fc35b3cb6e35fa5e8209a95840dd838875a94f6d8dfcd5730c4e
MD5 b0b02187f089561ec5303f4c6f30edd4
BLAKE2b-256 6ddfa03480d2015f6b8c97a36291e606899f5ec93f1a0c022347f6db05efbf61

See more details on using hashes here.

Supported by

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