Project

mailgems

0.0
No commit activity in last 3 years
No release in over 3 years
This library allows you to quickly and easily use the Mailgems API v1 via Ruby. It is also an Action Mailer adapter for using Mailgems in Rails apps. It uses the Mailgems HTTP API internally.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 0.8.23
>= 2.6.0, ~> 2.6
~> 0.12.2
~> 10.0
~> 3.0
~> 0.87.1
~> 3.5.1

Runtime

>= 0.17.0, <= 0.18.1
~> 2.2
 Project Readme

Gem Version Build Status Coverage Status

Mailgems

This library allows you to quickly and easily use the Mailgems API v1 via Ruby. It is also an Action Mailer adapter for using Mailgems in Rails apps. It uses the Mailgems HTTP API internally.

Installation

Add this line to your application's Gemfile:

gem 'mailgems'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mailgems

Usage

Here's how to send a message using the library:

require 'mailgems'

# First, instantiate the Mailgems Mail with your API key
mg_client = Mailgems::Mail.new(api_key: 'your-api-key')

# Define your mail parameters
mail_params = {
	from_email: 'foo@sending_domain.com',
	from_name: 'Foo',
	recipients: [{
		email: 'receiver@example.com',
		attributes: { name: 'Receiver' }
	}],
	subject: 'The Mailgems Ruby SDK is awesome!',
	content: 'Hi {{name}}, It is really easy to send an email!'
}

# Send your mail through the client
mg_client.send_mail mail_params

Rails

Mailgems.configure do |config|
	config.api_key = 'your-api-key'
	config.sandbox = false
end

Or have the initializer read your environment setting if you prefer.

To use as the ActionMailer delivery method, add this to your config/environments/whatever.rb:

	config.action_mailer.delivery_method = :mailgems

To specify Mailgems options such as template (body) or merge_data:

class UserMailer < ApplicationMailer
  def welcome_email
    mail(to: params[:to], subject: "Welcome!", body: 'mailgems-template-name', merge_data: { name: params[:name] })
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/mailgems/mailgems-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Mailgems project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.