action_recipient 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cc0328a3fee287b6d87961ca7185415ad295417d16596243e41b430ad547237
4
- data.tar.gz: e13218290718ae0b7894c952df71fcfbdfa9df4cece3ffb80dc69dbd604ba832
3
+ metadata.gz: 200eadc692f55fd4253823211aad73f9da3ce764db8da5526101ba08792421a5
4
+ data.tar.gz: 5e2de7f64a2fa5cc2b0e0eb1906f2e033e24b6e86ec089eebea5d072936017eb
5
5
  SHA512:
6
- metadata.gz: efd2145204838e48b8e321123bd515f06a1fce905a1b7a5c9a8cc4076150cbd5a313ec52abb878afb106a5c671732706a75b381b39bac44f70d13e7d58cfa217
7
- data.tar.gz: c608b3addea71fa100485dddc29c9aaf0b885383dc32d0522ced6af87154c37766d0f893e7e291c94467fa502d7c73e46bf261e985b09cf99c118bae9a8738f1
6
+ metadata.gz: 1d67685b2e4dec21fee76aa8566413d4eebf02b3c857a6993c5cfdb4dd82347851058c7e5dc8936a4bc14d062f7e9196c4ba9bfc31e8a8cabeac8a95bb34b2a5
7
+ data.tar.gz: 9ffef13353d2a2e27a75c0185902937c0a7e5eb60f86204807487a64c4820a963ff08d825e7aeb590835a708adfeb9133f292b39aaea1393cb1aa7e650e8d876
data/README.md CHANGED
@@ -1,6 +1,18 @@
1
+ ![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/fursich/action_recipient?color=green&style=plastic)
2
+ ![GitHub](https://img.shields.io/github/license/fursich/action_recipient?color=green&style=plastic)
3
+ ![Travis (.org)](https://img.shields.io/travis/fursich/action_recipient?color=green&style=plastic)
4
+
1
5
  # ActionRecipient
2
6
 
3
- Overwrites email recipients with ActionMailer emails to prevent accidental delivery in non-production environments.
7
+ This gem overwrites email recipients addresses sent by ActionMailer , so that to prevent your application from dispatching emails accidentally to existing addresses, expecially your users or clients in non-production environments.
8
+
9
+ ### IMPORTANT NOTES
10
+
11
+ * this gem is developed and tested carefully, but it does NOT mean this is 100% reliable. Please use this at your own risks, and test carefully before use.
12
+
13
+ * It HAS NO EFFECT on the Non-Actionmailer emails (i.e. if the emails are delivered out of ActionMailer's control)
14
+
15
+ * for example, if you are sending batch emails directly via Mailgun API, the gem cannot overwrite its addresses - please consider managing recipient addresses on your own.
4
16
 
5
17
  ## Installation
6
18
 
@@ -20,7 +32,77 @@ Or install it yourself as:
20
32
 
21
33
  ## Usage
22
34
 
23
- TODO: Write usage instructions here
35
+ ### Getting Started
36
+
37
+ Let's say you want to trap all the emails that are sent out in staging environment. You need to replace outgoing emails' addresses to your work address `your_address_to_redirect@gmail.com`, with a few exception such as `my_personal_adddress@example.com`
38
+
39
+ In `config/initializers`, register ActionRecipient as follows:
40
+
41
+ ```ruby
42
+ # config/initializers/action_recipient.rb
43
+
44
+ if Rails.env.staging? # works only in staging environment
45
+
46
+ ActionRecipient.configure do |config|
47
+ config.format = 'your_address_to_redirect+%s@gmail.com'
48
+
49
+ config.whitelist = [
50
+ 'safe_address@example.com',
51
+ 'my_personal_adddress@example.com'
52
+ ]
53
+ end
54
+
55
+ ActionMailer::Base.register_interceptor(ActionRecipient::Interceptor)
56
+ end
57
+ ```
58
+
59
+ Then, if you send an email to `admin@your_client.com` using ActionMailer, this gem traps it and overwrites its addresses as `your_address_to_redirect+admin_at_your_client.com@gmail.com`.
60
+
61
+ You can find the email at your mailbox in `your_address_to_redirect@gmail.com`, just as your client would do if it were in production - with the only difference in its `to` address that are slightly modified.
62
+
63
+ ### Detailed Settings
64
+
65
+ 1. set your "safe address" to indicate ActionRecipient an address to redirect outgoing emails:
66
+
67
+ ```ruby
68
+ ActionRecipient.configure do |config|
69
+ config.format = 'your_address_to_rediredt+%s@gmail.com'
70
+ end
71
+ ```
72
+
73
+ If you add **%s** in the format, it is automatically replaced with the original addresses after a few modifications. (see overwriting rules for deatils)
74
+
75
+ **DO NOT FORGET to specify a format**, otherwise your email addresses are not properly transformed, and your emails will not be successfully delivered.
76
+
77
+ 2. you could also set a collection of whitelisted mails:
78
+
79
+ ```ruby
80
+ ActionRecipient.configure do |config|
81
+ config.whitelist = [
82
+ 'my_personal_address@example.com',
83
+ 'my_colleagues_address@example.com'
84
+ ]
85
+ end
86
+ ```
87
+
88
+ Whitelisted emails addresses are not overwritten, thus can be delivered as usual.
89
+
90
+ 3. register ActionRecipient as the interceptor
91
+
92
+ ```ruby
93
+ ActionMailer::Base.register_interceptor(ActionRecipient::Interceptor)
94
+ ```
95
+
96
+ And you are good to go!
97
+
98
+ ### Overwriting Rules
99
+
100
+ The original address is being transformed as follows:
101
+
102
+ - `@` is replaced with `_at_`
103
+ - any alphabetical/numeric charactors are preserved
104
+ - any dots `.` and underscores `_` are preserved as well
105
+ - any other charactors are replaced with hyphens `-`
24
106
 
25
107
  ## Development
26
108
 
@@ -30,7 +112,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
30
112
 
31
113
  ## Contributing
32
114
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/action_recipient.
115
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fursich/action_recipient.
34
116
 
35
117
  ## License
36
118
 
@@ -1,3 +1,3 @@
1
1
  module ActionRecipient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_recipient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koji Onishi