A client API to the MailGun Email RESTful API.

You can sign up for a free account at:

https://signup.mailgun.com/new/signup

And the latest API documentation is available at:

https://documentation.mailgun.com/en/latest/

To access direct calls to the service, you will want to use the MailgunEx.Api module. When making requests, you can provide several opts, all of which can be defaulted using Mix.Config.

Here is an example of how to configure this library

config :mailgun_ex,
  base: "https://api.mailgun.net/v3",
  mode: :live,
  domain: "namedb.org",
  api_key: "key-3ax6xnjp29jd6fds4gc373sgvjxteol0",
  http_opts: %{
    timeout: 5000,
  }

The configs use a library called Deferred Config so that you can use environment variables that will be loaded at runtime, versus compiled into the release.

Here’s an example of how to use the system variables

config :mailgun_ex,
  base: "https://api.mailgun.net/v3",
  mode: {:system, "MAILGUN_MODE", :live, {String, :to_atom}},
  domain: {:system, "MAILGUN_DOMAIN", "defaultname.com"} ,
  api_key: {:system, "MAILGUN_API_KEY"},
  http_opts: %{
    timeout: 5000,
  }

Our default mix test tests will use Bypass as the base service URL so that we will not hit your production MailGun account during testing.

Here is an outline of all the configurations you can set.

This client library uses HTTPoison for all HTTP communication, and we will pass through any :http_opts you provide, which we have shown below.

If these are out of date, please push a Pull-Request to mailgun_ex “””

@doc “”” Issues an HTTP request with the given method to the given url_opts.

Args:

The options above can be defaulted using Mix.Config configurations, as documented above.

This function returns {<status_code>, response} if the request is successful, and {:error, reason} otherwise.

Installation

@deps [
  mailgun_ex: "~> 0.2.6"
]

Examples

MailgunEx.request(:get, resource: "domains")

License

MIT