Skip to content

Add Mailme adapter for email delivery #16

Description

@joamag

Problem (Why)

Pushi currently sends email only through raw SMTP, which requires each deployment to manage its own mail server credentials, deliverability and TLS configuration. Hive Solutions already runs Mailme, a simple REST email gateway with an official Python client (mailme-api), that removes that operational burden. Adding a Mailme adapter lets pushi apps send email through the managed gateway with just an API key, as an alternative to the SMTP handler.

Description (What)

Introduce a MailmeHandler adapter that delivers pushi events as emails via the Mailme REST gateway, with a Mailme subscription model, REST controller and API client mirroring the SMTP adapter. Recipient addresses are stored per subscription and overridable per published event, with subject/content derived from the event payload. Configuration uses Mailme's own convention (MAILME_BASE_URL, MAILME_KEY) alongside App-model fields, consistent with the existing credential pattern.

Implementation (How)

  1. Add MailmeHandler(handler.Handler) in src/pushi/base/mailme.py implementing load, add, remove, subscribe, unsubscribe, send(app_id, event, json_d, invalid={}) and a direct send_to_receivers(...); honor per-event receiver/subject overrides over the stored subscription.
  2. Prefer the mailme-api Python client (pip install mailme-api) if available, with a netius.clients.HTTPClient POST to MAILME_BASE_URL as a fallback; guard the import like the existing py_vapid optional dependency.
  3. Add App-model config fields in src/pushi/app/models/app.py (mailme_base_url, mailme_key) with global env-var fallbacks (MAILME_BASE_URL, MAILME_KEY) via appier.conf.
  4. Add the Mailme subscription model in src/pushi/app/models/mailme.py with fields (email, event) and handler-sync lifecycle hooks.
  5. API: add a MailmeController in src/pushi/app/controllers/mailme.py exposing GET/POST /mailmes and DELETE /mailmes/<email>.
  6. API client: add MailmeAPI in src/pushi/api/mailme.py with create_mailme / delete_mailme / subscribe_mailme / unsubscribe_mailme.
  7. Register the handler in State.load_handlers() in src/pushi/base/state.py and export new symbols from the four __init__.py files.
  8. Add mailme-api as an optional dependency in setup.py/requirements.txt.
  9. Add tests in src/pushi/test/mailme.py (payload/auth, per-event override, subscription sync, optional-client fallback) using the mock-owner pattern.
  10. Update README.md, add an examples/mailme/ example, and add a [Unreleased] CHANGELOG entry.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions