GithubHelp home page GithubHelp logo

mailgunner's Introduction

mailgunner

Ruby client for the Mailgun API.

Installation

$ gem install mailgunner

Quick start

require 'mailgunner'

mailgun = Mailgunner::Client.new({
  domain: 'samples.mailgun.org',
  api_key: 'key-3ax6xnjp29jd6fds4gc373sgvjxteol0'
})

response = mailgun.get_stats(limit: 5)

Storing the API key

Best practice for storing credentials for external services is to use environment variables, as described by 12factor.net/config. Mailgunner::Client defaults to extracting the domain and api_key values it needs from the MAILGUN_API_KEY and MAILGUN_SMTP_LOGIN environment variables. These will exist if you are using Mailgun on Heroku, or you can set them manually.

ActionMailer integration

Mailgunner integrates with ActionMailer. If you are using Rails, you can use Mailgunner to send mail via Mailgun by adding the following line to config/environments/production.rb:

config.action_mailer.delivery_method = :mailgun

Outside of Rails you can set ActionMailer::Base.delivery_method directly.

Email validation

If you only need to use Mailgun's email address validation service, you can instead use your Mailgun public key to authenticate like this:

require 'mailgunner'

public_key = 'pubkey-5ogiflzbnjrljiky49qxsiozqef5jxp7'

mailgun = Mailgunner::Client.new(api_key: public_key)

response = mailgun.validate_address('[email protected]')

mailgunner's People

Contributors

timcraft avatar ctide avatar

Watchers

Rubén Dávila Santos avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.