Email from Elixir and Phoenix through Notix.
Phoenix apps send through Swoosh, and Swoosh has an SMTP adapter, so the relay is the shortest path: your existing mailers keep working. There is no Elixir SDK; when you want the message id back or an idempotency key, call the JSON API with Req.
Send an email from Elixir and Phoenix.
config :my_app, MyApp.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: "smtp.usenotix.dev",
port: 587,
username: "notix",
password: System.fetch_env!("NOTIX_API_KEY"),
tls: :always,
auth: :always
Req.post!("https://app.usenotix.dev/api/v1/emails",
auth: {:bearer, System.fetch_env!("NOTIX_API_KEY")},
headers: [{"idempotency-key", "order-#{order.id}-receipt"}],
json: %{
from: "Acme <receipts@acme.com>",
to: order.email,
subject: "Your receipt",
html: "<p>Thanks for your order.</p>"
}
)
The from address must be on a domain you have verified in Notix. Step by step: the SMTP quickstart.
One API key, kept on the server.
Create an API key on the API keys page of the Notix console and store it as NOTIX_API_KEY in the release environment, read in config/runtime.exs. Read it only in code that runs on the server, never in anything shipped to a browser.
A Send only key is enough for code that only sends: if it leaks, it cannot read your contacts or delete a domain.
NOTIX_API_KEY=notix_xxxxxxxxxxxx
NOTIX_WEBHOOK_SECRET=whsec_xxxxxxxxxxxx
Questions, answered.
Is there a Notix Elixir library?
Which port should Swoosh use?
Why is my send refused with a from-address error?
Send your first email in five minutes.
Verify a domain, copy an API key, make one call. The free plan does not ask for a card.