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

Raised when email delivery fails.

## Types

- `:adapter_failure` — the Swoosh adapter returned an error
- `: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
- `:dispatch_unavailable` — local async admission was refused before work started

## Per-kind Fields

- `:delivery_id` — binary reference to the failed `%Mailglass.Delivery{}`
  record when available (lands in ). `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(),
  retry_class: :transient | :permanent | nil,
  type:
    :adapter_failure
    | :rendering_failed
    | :preflight_rejected
    | :serialization_failed
    | :dispatch_unavailable
}
```

# `__types__`
*since 0.1.0* 

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.
- `:retry_class` — `:transient`, `:permanent`, or `nil`; excluded from JSON output.

---

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