# `Mailglass.SendError`
[🔗](https://github.com/szTheory/mailglass/blob/v0.1.0/lib/mailglass/errors/send_error.ex#L1)

Raised when email delivery fails.

## Types

- `:adapter_failure` — the Swoosh adapter returned an error (retryable)
- `:rendering_failed` — HEEx or CSS-inlining pipeline failed
- `:preflight_rejected` — suppression or rate-limit check blocked the send
- `:serialization_failed` — message could not be serialized for the adapter

## Per-kind Fields

- `:delivery_id` — binary reference to the failed `%Mailglass.Delivery{}`
  record when available (lands in Phase 2). `nil` when the failure occurred
  before the delivery row was persisted.

See `Mailglass.Error` for the shared contract and `docs/api_stability.md`
for the locked `:type` atom set.

# `t`

```elixir
@type t() :: %Mailglass.SendError{
  __exception__: true,
  cause: Exception.t() | nil,
  context: %{required(atom()) =&gt; term()},
  delivery_id: binary() | nil,
  message: String.t(),
  type:
    :adapter_failure
    | :rendering_failed
    | :preflight_rejected
    | :serialization_failed
}
```

# `__types__`
*since 0.1.0* 

```elixir
@spec __types__() :: [atom()]
```

Returns the closed set of valid `:type` atoms. Tested against `docs/api_stability.md`.

# `new`
*since 0.1.0* 

```elixir
@spec new(
  atom(),
  keyword()
) :: t()
```

Build a `Mailglass.SendError` struct.

## Options

- `:cause` — an underlying exception to wrap (kept out of JSON output).
- `:context` — a map of non-PII metadata about the failure.
- `:delivery_id` — the `%Mailglass.Delivery{}` id when available.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
