Pew Pew

A Ruby client library for using the Mailgun web service.

Build Status


Add this line to your application's Gemfile:

gem 'pew_pew'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pew_pew


You must have a valid API key to use the Mailgun API. If you don't yet have one, you can sign up here.

You can use the following method to configure your API key and domain:

PewPew.configure do |config|
  config.api_key = ENV['MAILGUN_API_KEY']
  config.domain = ENV['MAILGUN_DOMAIN'] # optional

If you'd like to use multiple instances of the API with different keys, you can instantiate PewPew::Client directly and treat those instances the same as you would the PewPew module:

pew_pew =

pew_pew.configure do |config|
  config.api_key = ENV['MAILGUN_API_KEY']
  config.domain = ENV['MAILGUN_DOMAIN'] # optional


Once the API key has been configured, resources can be called on the PewPew module directly or off your client instances:

  to: '',
  from: '',
  subject: 'Test',
  text: 'This is a test message.'

For resources that require a domain, you may pass it as an option when calling the resource. If a domain has been configured, it will be used as the default for all methods called on the resource.

PewPew.stats.all # uses the configured domain
PewPew.stats(domain: '').all # uses

See the documentation for the complete list of resources.


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature.')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request