Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/SparkPost/elixir-sparkpost

SparkPost client library for Elixir https://developers.sparkpost.com
https://github.com/SparkPost/elixir-sparkpost

elixir email sparkpost

Last synced: 2 months ago
JSON representation

SparkPost client library for Elixir https://developers.sparkpost.com

Awesome Lists containing this project

README

        

[Sign up](https://app.sparkpost.com/join?plan=free-0817?src=Social%20Media&sfdcid=70160000000pqBb&pc=GitHubSignUp&utm_source=github&utm_medium=social-media&utm_campaign=github&utm_content=sign-up) for a SparkPost account and visit our [Developer Hub](https://developers.sparkpost.com) for even more content.

# SparkPost Elixir Library

[![Travis CI](https://travis-ci.org/SparkPost/elixir-sparkpost.svg?branch=master)](https://travis-ci.org/SparkPost/elixir-sparkpost) [![Coverage Status](https://coveralls.io/repos/SparkPost/elixir-sparkpost/badge.svg?branch=master&service=github)](https://coveralls.io/github/SparkPost/elixir-sparkpost?branch=master)

The official [Elixir](http://elixir-lang.org/) package for the [SparkPost API](https://www.sparkpost.com/api).

Capabilities include:
- convenience functions for easy "I just want to send mail" users
- advanced functions for unleashing all of Sparkpost's capabilities

## Installation

1. Add sparkpost and ibrowse to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:sparkpost, "~> 0.5.1"}
]
end
```

2. Ensure sparkpost is started before your application:

```elixir
def application do
[applications: [:sparkpost]]
end
```

3. Update your dependencies:

```bash
$ mix deps.get
```

## Usage

### Configuration

In your config/config.exs file:

```elixir
config :sparkpost, api_key: "YOUR-API-KEY"
```

### Option 1: Convenience

```elixir
defmodule MyApp.Example do
def send_message do
SparkPost.send to: "[email protected]",
from: "[email protected]",
subject: "Sending email from Elixir is awesome!",
text: "Hi there!",
html: "

Hi there!

"
end
end
```

### Option 2: Full SparkPost API

```elixir
defmodule MyApp.Example do
alias SparkPost.{Content, Recipient, Transmission}

def send_message do
Transmission.send(%Transmission{
recipients: [ "[email protected]" ],
content: %Content.Inline{
subject: "Sending email from Elixir is awesome!",
from: "[email protected]",
text: "Hi there!",
html: "

Hi there!

"
}
})
end
end
```

Start your app and send a message:

```bash
$ iex -S mix
iex> MyApp.Example.send_message
{:ok, ...}
```

### Contribute

We welcome your contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to help out.

### Change Log

[See ChangeLog here](CHANGELOG.md)