[Elixir SDK]
Phoenix
Send email from Phoenix controllers and LiveView with the Elixir client.
Step 1
Install the package
Add the official Elixir client to your Phoenix project.
bash
{:reloop, "~> 0.1.0"}Step 2
Set your API key
Create a free Reloop account, copy your API key, and add it to your Phoenix environment.
Get an API key free →bash
RELOOP_API_KEY="re_xxxxxxxx"Step 3
Send email from Phoenix
Use this Phoenix snippet to send your first message. Works with Controllers · LiveView · OTP.
send_email.ex
1defmodule MyAppWeb.EmailController do2 use MyAppWeb, :controller3
4 def create(conn, %{"to" => to}) do5 client = Reloop.client(api_key: System.get_env("RELOOP_API_KEY"))6
7 case Reloop.Emails.send(client, %{8 from: "Acme <onboarding@yourdomain.com>",9 to: [to],10 subject: "Hello from Phoenix",11 html: "<strong>It works!</strong>"12 }) do13 {:ok, email} -> json(conn, %{id: email.id})14 {:error, reason} -> conn |> put_status(500) |> json(%{error: inspect(reason)})15 end16 end17endNext steps
Examples, docs, and API reference
Go deeper with working code and the full API for Elixir.
Other frameworks
Same API, framework-specific examples.
Send with Phoenix.
Get an API key and ship transactional email from Phoenix using the official Elixir SDK.