rails-mailgun 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 416599af643ce06b2287dc7a210b48cbb11b9322
4
+ data.tar.gz: 441ecec58ee0e2b572cc2b1bab9a80ed3890fc86
5
+ SHA512:
6
+ metadata.gz: 41fa9bb189c2927505fb437c4a406732c5c0bd9a3df8f97bffb1a3de9efc9069595b1c1434c157626114cf46d927ab8e3ce1afbe4740c0c001c6d980db444674
7
+ data.tar.gz: 53c458a6d56040cf53661fc88044ff9d541f4a79f18e88d4160ebc8514966f39a56014e4585b80f199424874be1b2f82ca243c38a5825fa3317f621434b358d1
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Codemancers Tech Pvt Ltd
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # RailsMailgun
2
+ [![Build Status](https://travis-ci.org/code-mancers/rails-mailgun.png?branch=master)](https://travis-ci.org/code-mancers/rails-mailgun)
3
+ [![Code Climate](https://codeclimate.com/github/code-mancers/rails-mailgun.png)](https://codeclimate.com/github/code-mancers/rails-mailgun)
4
+
5
+ Mailgun integration for rails
6
+
7
+
8
+ ## Installation
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'mailgun', git: "git://github.com/code-mancers/rails-mailgun.git"
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+ Mailgun needs 2 config variables.
19
+
20
+ 1. `api_host` : the domain which you have used for registration
21
+ 2. `api_key` : the api key for access. it starts with `key-`
22
+
23
+ Add these lines to your `environment/production.rb` file
24
+
25
+ ```ruby
26
+ Your::Application.configure do
27
+ # ....
28
+
29
+ # mailgun deilvery method
30
+ config.action_mailer.delivery_method = :mailgun
31
+ config.action_mailer.mailgun_settings = {
32
+ api_host: "samples.mailgun.org",
33
+ api_key: "key-3ax6xnjp29jd6fds4gc373sgvjxteol0"
34
+ }
35
+ end
36
+ ```
37
+
38
+ ## Running the specs
39
+ Specs can be run via:
40
+
41
+ bundle exec rspec spec/*_spec.rb
42
+
43
+ ## TODO
44
+ 1. Add error handling once the response is received from mailgun
45
+ 2. Write a helper rake task to quickly check whether integration is working or not!
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'RailsMailgun'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
@@ -0,0 +1,8 @@
1
+ require "rails-mailgun/engine"
2
+ require "rails-mailgun/mail"
3
+ require "rest-client"
4
+
5
+ module RailsMailgun
6
+ end
7
+
8
+ ActionMailer::Base.add_delivery_method :mailgun, RailsMailgun::Mail
@@ -0,0 +1,4 @@
1
+ module RailsMailgun
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,30 @@
1
+ module RailsMailgun
2
+ class Mail
3
+ def initialize(settings)
4
+ @settings = settings
5
+ end
6
+ attr_accessor :settings
7
+
8
+ def deliver!(mail)
9
+ RestClient.post message_url, message_params(mail)
10
+ end
11
+
12
+ private
13
+ def message_url
14
+ "https://api:#{settings[:api_key]}@api.mailgun.net/v2/#{settings[:api_host]}/messages"
15
+ end
16
+
17
+ def message_params(mail)
18
+ message_params = {
19
+ from: mail.from.join(" "),
20
+ to: mail.to.join(", "),
21
+ subject: mail.subject
22
+ }
23
+
24
+ type = mail.content_type.match(/html/) ? :html : :text
25
+ message_params[type] = mail.body.to_s
26
+
27
+ message_params
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module RailsMailgun
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-mailgun
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuva Kumar
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.0
55
+ description:
56
+ email:
57
+ - yuva@codemancers.com
58
+ - hello@codemancers.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - lib/rails-mailgun/engine.rb
64
+ - lib/rails-mailgun/mail.rb
65
+ - lib/rails-mailgun/version.rb
66
+ - lib/rails-mailgun.rb
67
+ - MIT-LICENSE
68
+ - Rakefile
69
+ - README.md
70
+ homepage: https://github.com/code-mancers/rails-mailgun
71
+ licenses: []
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.0.3
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: Mailgun integration for rails
93
+ test_files: []