SDK's

Elixir

Officiële Elixir SDK voor WeSender, beschikbaar als Hex-package. Gebouwd op Req: modern, compact en standaard in de Elixir-community.

github.com/nljerry/wesender-elixir

Installatie

Voeg toe aan je mix.exs:

defp deps do
  [
    {:wesender, "~> 1.0"}
  ]
end

E-mail versturen

curl -X POST https://api.wesender.nl/emails \
  -H "Authorization: Bearer $WS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"from":"noreply@joudomein.nl","to":"klant@voorbeeld.nl","subject":"Hallo!","html":"<p>Welkom!</p>"}'

Phoenix context

# Phoenix/Plug context module
defmodule MijnApp.Mailer do
  @api_url "https://api.wesender.nl/emails"

  def verstuur_welkomstmail(naam, email) do
    Req.post!(@api_url,
      auth: {:bearer, System.fetch_env!("WS_API_KEY")},
      json: %{
        from:    "noreply@joudomein.nl",
        to:      email,
        subject: "Welkom, #{naam}!",
        html:    "<p>Bedankt voor je aanmelding bij ons platform.</p>"
      }
    )
  end
end

Volgende stappen