https://github.com/mylanconnolly/pewpew
A minimal Mailgun client for Elixir
https://github.com/mylanconnolly/pewpew
elixir mailgun
Last synced: 4 months ago
JSON representation
A minimal Mailgun client for Elixir
- Host: GitHub
- URL: https://github.com/mylanconnolly/pewpew
- Owner: mylanconnolly
- License: mit
- Created: 2017-08-29T17:35:44.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-20T20:14:44.000Z (over 8 years ago)
- Last Synced: 2025-10-24T04:43:03.212Z (8 months ago)
- Topics: elixir, mailgun
- Language: Elixir
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PewPew
This is a minimal client for the [mailgun](https://mailgun.com) service.
Why does it exist? While dealing with the mailgun API is pretty straightforward,
I wanted to create a simple hex package that I could reuse across my other
systems that might need it later on.
## Installation
Add to your dependencies:
```elixir
def deps do
[{:pewpew, "~> 0.1.0"}]
end
```
## Usage
First, set some configuration options in `config.exs` (or the env-specific
version):
```elixir
use Mix.Config
config :pewpew,
from: "default `from` address",
key: "your API key from mailgun",
domain: "the domain you wish to use in mailgun"
```
You can then create and send a mailer like so:
```elixir
# Create a new mailer
m = PewPew.Mailer.new(
to: "test@example.com",
subject: "A subject!",
text: "Plain-text body"
)
# Send the mailer
PewPew.Mailer.send(m)
```
There are a number of functions inside the `PewPew.Mailer` class, and they're
hopefully pretty easy to understand. The functions are designed to be easily
integrated inside a pipeline, so you can modify the struct pretty easily if you
do not have all of the attributes at the time of creation. As an example:
```elixir
PewPew.Mailer.new()
|> PewPew.Mailer.set_to("test@example.com")
|> PewPew.Mailer.set_cc("test@another-example.com")
|> PewPew.Mailer.set_bcc("sneaky@example.com")
|> PewPew.Mailer.set_subject("Hello!")
|> PewPew.Mailer.set_text("This is some text content")
|> PewPew.Mailer.set_html("
Some fancy HTML content!
")
|> PewPew.Mailer.send()
```
Full documentation for this project can be found at
[https://hexdocs.pm/pewpew](https://hexdocs.pm/pewpew).