Skip to main content

Module email

Module email 

Source
Expand description

Email delivery abstraction.

Doctrine 6: email is operational infrastructure, not business logic. Recovery flows compose Mail objects with a fixed envelope (Mail::framework_envelope) and dispatch them through a project-supplied Mailer implementation. The framework refuses to lock into SMTP — projects ship whatever transport their organisation already uses (SES, Mailgun, Postmark, internal relay, queued background job, etc.).

§What the framework provides

  • The Mailer trait — one async method, send.
  • LogMailer — the safe default. Writes the would-be email to log::info! so reset links stay visible during dev / CI without a mail server. Not suitable for production: in production a real mailer must be configured or recovery emails will be silently lost.
  • Mail + Mail::framework_envelope for canonical headers (timestamp, source IP, browser/OS summary, “if this was not you” guidance) per doctrine 6.

§Project override

let admin = Admin::new()
    .mailer(Arc::new(MyProjectMailer::new(/* SES, Mailgun, … */)));

The default is LogMailer — projects opt in to a real mailer by registering one. R1+ recovery flows will read the configured mailer from Admin and refuse to boot in production mode if none is registered.

Structs§

LogMailer
Default mailer. Writes the message to log::info! instead of sending it. Safe for dev / CI / testing where outbound SMTP is forbidden or undesirable; not suitable for production — recovery emails will be lost (the audit row will record the attempt).
Mail
One outbound message. Plaintext body is required; HTML is optional. Extra headers are project-controlled.
RecoveryEmailParts
Structured inputs to render_recovery_html. Kept separate from Mail so the framework’s HTML email surface stays declarative — call-sites pass labelled fields rather than a long positional argument list.

Enums§

MailerError
Errors a Mailer can return. The most important variant is MailerError::ConfigurationMissing — the framework treats it as a hard boot failure when production deployments forget to wire up a real mailer (per the user-locked decision: “Mailer blocking behaviour” → refuse to start when no mailer is configured for production).

Traits§

Mailer
Async outbound-mail interface. Project implementations live in the project crate so the framework never imports lettre / aws-sdk-ses / etc.

Functions§

render_recovery_html
Render the framework’s polished HTML body for a recovery / magic-link email. The visual treatment matches DESIGN_CHROME.md: calm typography, a single brand-accent point of emphasis (the CTA button), hairline separation, table-based layout for email- client compatibility, inlined CSS for clients that strip <style> blocks, and a @media query for mobile readability.

Type Aliases§

SharedMailer
Type-erased shared mailer reference. The framework’s Admin holds one of these; defaults to Arc::new(LogMailer) until a project overrides via Admin::mailer(Arc::new(...)).