0.0
No commit activity in last 3 years
No release in over 3 years
A library for interfacing with the Mailgun API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.5
 Project Readme

mailgun_api rubygem

A library for interfacing with the awesome Mailgun API.

See: http://www.mailgun.com/

mailgun_api exposes the following resources:

  • Sending email
  • Mailing Lists
  • Mailing List Members

Usage

Installation

gem install mailgun_api

Include in your ruby file(s)

require 'mailgun_api'

Configuration

# Initialize Mailgun (set defaults):
Mailgun.configure do |config|
  config.api_key = 'your-api-key-xxxxxxxxxxxxxxx'
  config.domain = 'your_domain.mailgun.org'
end

@mailgun = Mailgun.new


# Initialize Mailgun (custom for each object):
@mailgun = Mailgun.new(api_key: 'your-api-key-xxxxxxxxxxxxxxx', domain: 'your_domain.mailgun.org')

Mailing Lists

# List all Mailing lists
@mailgun.lists

# Find a mailing list - Will search for 'list@your_domain.mailgun.org'
@list = @mailgun.find_list("list")

# Create a mailing list - Will create 'list@your_domain.mailgun.org'
@list = @mailgun.create_list("list")

# Create a mailing list - With additional properties
@list = @mailgun.create_list('list_address', {description: "my description", name: "my name"})

# Update mailing list properties
@list.update({description: "My Description"})

# Delete the mailing list
@list.delete


# Get the raw list properties
@list.properties

# Other properties can be accessed as well
@list.members_count
@list.description
@list.created_at
@list.access_level
@list.address
@list.name

# Get the list of mailing list members.
@list.members

# Get the list stats
@list.stats

List Members

# Find a member in the list
@list.find_member("alice@example.com")

# Add a member to the list (using email address only)
@list.add_member("alice@example.com")

# Add a member to the list (using hash)
@list.add_member({address: "alice@example.com", name: "Alice Smith"})

# Add multiple members
@list.add_member([{address: "Alice <alice@example.com>", vars: {age: 26}}, {name: "Bob", address: "bob@example.com", vars: {age: 34} }])

# Update member
@list.update_member("bob@example.com", {address: "bob@newdomain.com", name: "Robert Smith", subscribed: false})

# Remove member
@list.remove_member("alice@exampe.com")

Domains

# List all domains
@mailgun.domains

# List domain specifics
@mailgun.find_domain("example.com")

Messages

# Create a message
@message = @mailgun.create_message({})

# Send a message to a list
@list.send_message(@message, when: "Fri, 25 Oct 2011 23:10:10 -0000")

Author

Michael Irey / @michaelirey

License

Released under the MIT license. See LICENSE for more details.