Send an email with Thinwrap (Elixir)

Send transactional email via :thinwrap_notifications.send_email/2 in Elixir — one call shape for SendGrid, AWS SES, Resend and 7 more.

1. Install

{:thinwrap_notifications, "~> 1.2"}

2. Send the call

config = %{
  provider: :sendgrid,
  api_key: System.fetch_env!("SENDGRID_API_KEY"),
  from: "noreply@example.com"
}

case :thinwrap_notifications.send_email(config, %{
       to: "user@example.com",
       subject: "Hello from Thinwrap",
       text: "Hello world"
     }) do
  # status is :sent | :queued | :rejected | :suppressed | :unknown
  # provider_message_id is the upstream message id, or ""
  {:ok, %{status: status, provider_message_id: id}} ->
    IO.puts("#{status} #{id}")

  {:error, %{code: code, message: message}} ->
    IO.puts("#{code}: #{message}")
end

Same code works for all supported providers — just change the provider ID.