Quick setup examples

Elixir

Send your first email from Elixir using Req against the MailBlastr API.

MailBlastr has no Elixir package — you send email by POSTing JSON to https://api.mailblastr.com/emails. The example below uses `Req`, a batteries-included HTTP client.

Prerequisites

1. Install an HTTP client

Add req to your dependencies in mix.exs, then run mix deps.get.

mix.exs
def deps do
  [
    {:req, "~> 0.5"}
  ]
end

2. Send email using HTML

Read the API key from the environment and POST the email body. The easiest way to send is with the html field.

send.exs
api_key = System.get_env("MAILBLASTR_API_KEY")

response =
  Req.post!("https://api.mailblastr.com/emails",
    auth: {:bearer, api_key},
    json: %{
      from: "Acme <onboarding@yourdomain.com>",
      to: ["delivered@example.com"],
      subject: "hello world",
      html: "<strong>it works!</strong>"
    }
  )

IO.inspect(response.body["id"])
In a Phoenix app, send from a controller action with the same body. See Send an email for every supported field.