Browse Source

Add mailing via Mailgun

Maarten van den Berg 8 years ago
parent
commit
d5cbb687dd
6 changed files with 35 additions and 1 deletions
  1. 3 0
      .gitignore
  2. 4 0
      .rbenv-vars-sample
  3. 3 0
      Gemfile
  4. 18 0
      Gemfile.lock
  5. 1 1
      app/mailers/application_mailer.rb
  6. 6 0
      config/environments/development.rb

+ 3 - 0
.gitignore

@@ -30,3 +30,6 @@ public/assets/*
30 30
 
31 31
 # Ignore IDEA
32 32
 .idea
33
+
34
+# Ignore secrets
35
+.rbenv-vars

+ 4 - 0
.rbenv-vars-sample

@@ -0,0 +1,4 @@
1
+MAILGUN_DOMAIN=
2
+MAILGUN_API_KEY=
3
+
4
+MAIL_FROM_ADDRESS=

+ 3 - 0
Gemfile

@@ -46,6 +46,9 @@ gem 'font-awesome-sass'
46 46
 # Use YARD for documentation
47 47
 gem 'yard'
48 48
 
49
+# Use Mailgun for mail
50
+gem 'mailgun_rails'
51
+
49 52
 # Use Capistrano for deployment
50 53
 # gem 'capistrano-rails', group: :development
51 54
 

+ 18 - 0
Gemfile.lock

@@ -56,6 +56,8 @@ GEM
56 56
     coffee-script-source (1.11.1)
57 57
     concurrent-ruby (1.0.2)
58 58
     debug_inspector (0.0.2)
59
+    domain_name (0.5.20161129)
60
+      unf (>= 0.0.5, < 1.0.0)
59 61
     erubis (2.7.0)
60 62
     execjs (2.7.0)
61 63
     faker (1.7.2)
@@ -67,6 +69,8 @@ GEM
67 69
       activesupport (>= 4.1.0)
68 70
     haml (4.0.7)
69 71
       tilt
72
+    http-cookie (1.0.3)
73
+      domain_name (~> 0.5)
70 74
     i18n (0.7.0)
71 75
     jbuilder (2.6.1)
72 76
       activesupport (>= 3.0.0, < 5.1)
@@ -75,6 +79,7 @@ GEM
75 79
       rails-dom-testing (>= 1, < 3)
76 80
       railties (>= 4.2.0)
77 81
       thor (>= 0.14, < 2.0)
82
+    json (2.0.3)
78 83
     listen (3.0.8)
79 84
       rb-fsevent (~> 0.9, >= 0.9.4)
80 85
       rb-inotify (~> 0.9, >= 0.9.7)
@@ -82,6 +87,10 @@ GEM
82 87
       nokogiri (>= 1.5.9)
83 88
     mail (2.6.4)
84 89
       mime-types (>= 1.16, < 4)
90
+    mailgun_rails (0.9.0)
91
+      actionmailer (>= 3.2.13)
92
+      json (>= 1.7.7)
93
+      rest-client (>= 1.6.7)
85 94
     method_source (0.8.2)
86 95
     mime-types (3.1)
87 96
       mime-types-data (~> 3.2015)
@@ -89,6 +98,7 @@ GEM
89 98
     mini_portile2 (2.1.0)
90 99
     minitest (5.10.1)
91 100
     multi_json (1.12.1)
101
+    netrc (0.11.0)
92 102
     nio4r (1.2.1)
93 103
     nokogiri (1.6.8.1)
94 104
       mini_portile2 (~> 2.1.0)
@@ -123,6 +133,10 @@ GEM
123 133
     rb-fsevent (0.9.8)
124 134
     rb-inotify (0.9.7)
125 135
       ffi (>= 0.5.0)
136
+    rest-client (2.0.1)
137
+      http-cookie (>= 1.0.2, < 2.0)
138
+      mime-types (>= 1.16, < 4.0)
139
+      netrc (~> 0.8)
126 140
     sass (3.4.22)
127 141
     sass-rails (5.0.6)
128 142
       railties (>= 4.0.0, < 6)
@@ -153,6 +167,9 @@ GEM
153 167
       thread_safe (~> 0.1)
154 168
     uglifier (3.0.4)
155 169
       execjs (>= 0.3.0, < 3)
170
+    unf (0.1.4)
171
+      unf_ext
172
+    unf_ext (0.0.7.2)
156 173
     web-console (3.4.0)
157 174
       actionview (>= 5.0)
158 175
       activemodel (>= 5.0)
@@ -180,6 +197,7 @@ DEPENDENCIES
180 197
   jbuilder (~> 2.5)
181 198
   jquery-rails
182 199
   listen (~> 3.0.5)
200
+  mailgun_rails
183 201
   puma (~> 3.0)
184 202
   rails (~> 5.0.0, >= 5.0.0.1)
185 203
   sass-rails (~> 5.0)

+ 1 - 1
app/mailers/application_mailer.rb

@@ -1,4 +1,4 @@
1 1
 class ApplicationMailer < ActionMailer::Base
2
-  default from: 'from@example.com'
2
+  default from: ENV['MAIL_FROM_ADDRESS']
3 3
   layout 'mailer'
4 4
 end

+ 6 - 0
config/environments/development.rb

@@ -51,4 +51,10 @@ Rails.application.configure do
51 51
   # Use an evented file watcher to asynchronously detect changes in source code,
52 52
   # routes, locales, etc. This feature depends on the listen gem.
53 53
   config.file_watcher = ActiveSupport::EventedFileUpdateChecker
54
+
55
+  config.action_mailer.delivery_method = :mailgun
56
+  config.action_mailer.mailgun_settings = {
57
+        api_key: ENV['MAILGUN_API_KEY'],
58
+        domain: ENV['MAILGUN_DOMAIN']
59
+  }
54 60
 end