Mailgun
Send multipart messages through a Mailgun sending domain and region.
Import mailgunEmailLayer from @corven/email-sdk/mailgun to provide the common Email service for this account.
Configure the account
import { Layer } from "effect";
import type { Redacted } from "effect";
import { mailgunEmailLayer } from "@corven/email-sdk/mailgun";
import { emailHttpLayer } from "./sending.js";
export const configuredMailgunAccount = (apiKey: Redacted.Redacted) =>
mailgunEmailLayer({ apiKey, domain: "mail.example.test", region: "UnitedStates" }).pipe(
Layer.provide(emailHttpLayer),
);
The example reuses the explicit HTTP Layer. Acquire credentials in trusted host code, then provide this account Layer to your sending program.
Message behavior
- The domain is a lowercase ASCII DNS name, not an API URL or account credential. Choose UnitedStates or Europe for the matching account.
- Custom headers retain repeated names. Metadata maps to v: fields and tags to o:tag; control headers cannot override SDK submission controls.
- Inline content IDs must equal the preserved filename. Scheduling requires whole seconds and a representable RFC-2822 year.
- mailgunPersonalizedEmailLayer is a separate opt-in native audience mode.
Idempotency
Idempotency keys are not supported. The SDK does not retry requests with unknown submission outcomes.
Read field support before switching accounts, and receipts and retries before adding recovery behavior. Configuration and local validation do not authenticate the account or prove delivery.