Skip to content

sendkitdev/sendkit-elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SendKit Elixir SDK

Official Elixir SDK for the SendKit email API.

Installation

Add to your mix.exs:

def deps do
  [
    {:sendkit, "~> 1.0"}
  ]
end

Usage

Create a Client

client = SendKit.new("sk_your_api_key")

Send an Email

{:ok, %{"id" => id}} =
  SendKit.Emails.send(client, %{
    from: "you@example.com",
    to: ["recipient@example.com"],
    subject: "Hello from SendKit",
    html: "<h1>Welcome!</h1>"
  })

Send a MIME Email

{:ok, %{"id" => id}} =
  SendKit.Emails.send_mime(client, %{
    envelope_from: "you@example.com",
    envelope_to: "recipient@example.com",
    raw_message: mime_string
  })

Error Handling

case SendKit.Emails.send(client, params) do
  {:ok, %{"id" => id}} ->
    IO.puts("Sent: #{id}")

  {:error, %SendKit.Error{name: name, message: message, status_code: code}} ->
    IO.puts("API error: #{name} (#{code}): #{message}")
end

Configuration

# Read API key from SENDKIT_API_KEY environment variable
client = SendKit.new()

# Custom base URL
client = SendKit.new("sk_...", base_url: "https://custom.api.com")

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages