safety_mailer 0.0.9 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 85f0d639f0e74a9a09b5b3c38120447f1e6a86bd
4
- data.tar.gz: 08ded9abda5cd2c321a78a36c6d8bfb03184450f
2
+ SHA256:
3
+ metadata.gz: f938efe60a4a91fe62371d6d49ac6d17b30caada23b12dd7ff12e3043a18fc7c
4
+ data.tar.gz: c28ec8454f91e49e5376bc43c438dafe718cd145789226b915526107811691fa
5
5
  SHA512:
6
- metadata.gz: 2fc2c5e076b8d7ccdbaf74d708ca25f10898981aa95b1a5f6e0fa03e69a0df855632cbd623624a52be6ed003bd5dae3eb15b8e95455ec05017d386b17cf1e3fe
7
- data.tar.gz: 50e7d8fb3a4af518bfd36354541a431e0284ea783ec881686c41fd4c46c5241c8572d2da4f2727ccfeeb09b7da3700dc09858b1bbaab88038b3ce60cf206920e
6
+ metadata.gz: 4a6e8a3831a85672c5f67f6385782361dc6799bec3a8eab18336fef9ff8913a617eab039fb1a30f175078f7930b1c29434eabaf356f20bf00822cd627d8ae109
7
+ data.tar.gz: 6d61949b2ad02dba4bd4aeb82e05434fb89f1deaab0b7d0e38d0231bc331601006b740649c0ea1079c21103f4fee398d300a395f1d8fbf9881237fb6e1c6cf6e
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ plugins:
2
+ - rubocop-rake
3
+ - rubocop-minitest
4
+
5
+ AllCops:
6
+ NewCops: disable
7
+
8
+ Metrics/MethodLength:
9
+ Max: 30
10
+
11
+ Metrics/AbcSize:
12
+ Max: 25
data/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-09-01
4
+
5
+ - Rebuilding on a modern gem framework
6
+ - Shiny new logo!
7
+ - Port testing to minitest
8
+ - Fix support for non-rails (Mail gem) usage
9
+ - Add support for custom loggers (e.g., non-rails)
10
+
11
+ ## [0.0.10] - 2014-12-04
12
+
13
+ - Support use separate from Mail gem
14
+
15
+ ## [0.0.9] - 2014-10-23
16
+
17
+ - Make `whitelisted?` public
18
+
19
+ ## [0.0.8] - 2014-06-14
20
+
21
+ - Added support for ActionMailer custom delivery methods
22
+
23
+ ## [0.0.7] - 2013-06-10
24
+
25
+ - Development enhancements
26
+
27
+ ## [0.0.6] - 2013-06-10
28
+
29
+ - SendGrid support
30
+ - X-SMTPAPI support
31
+
32
+ ## [0.0.5] - 2013-06-10
33
+
34
+ - Doc update
35
+
36
+ ## [0.0.4] - 2012-03-13
37
+
38
+ - Mail gem compatibility fix
39
+
40
+ ## [0.0.3] - 2012-02-12
41
+
42
+ - Rails 3.1 compatibility
43
+
44
+ ## [0.0.2] - 2012-02-09
45
+
46
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Bill Kirtley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,147 @@
1
+ # SafetyMailer
2
+
3
+ ![Logo](assets/logo_ruby_hardhat.png)
4
+
5
+ Restrict email sent by your application to only approved domains or accounts.
6
+
7
+ Specify a domain (or set of domains, or magic word in email address) email is allowed to go to, and email to all other domains is silently dropped.
8
+
9
+ This is useful for testing or staging environments where you want to be certain email to real customers doesn't escape the lab.
10
+
11
+ Layered on the Mail gem, so Rails >= 3.0 applications (as well as plain ruby apps) can use safety_mailer.
12
+
13
+ ## Installation
14
+
15
+ Add the gem to your +Gemfile+, specifying groups (probably not production) to include it in.
16
+
17
+ ```ruby
18
+ gem "safety_mailer", :group => :development
19
+ ```
20
+
21
+ Don't forget to `bundle install` to install
22
+
23
+ In your environment file `config/environments/development.rb` configure it, and some regular expressions.
24
+
25
+ ```ruby
26
+ config.action_mailer.delivery_method = :safety_mailer
27
+ config.action_mailer.safety_mailer_settings = {
28
+ allowed_matchers: [ /mydomain.com/, /mytestacct@gmail.com/, /\+safety_mailer@/ ],
29
+ delivery_method: :smtp,
30
+ delivery_method_settings: {
31
+ address: "smtp.mydomain.com",
32
+ port: 25,
33
+ domain: "mydomain.com",
34
+ authentication: :plain,
35
+ user_name: "mydomain_mailer@mydomain.com",
36
+ password: "password"
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## Logging
42
+
43
+ SafetyMailer supports custom logging to help you monitor email filtering decisions. By default, SafetyMailer will automatically use `Rails.logger` if available, or remain silent if no logger is configured.
44
+
45
+ ### Rails Applications
46
+
47
+ In Rails applications, SafetyMailer automatically uses `Rails.logger` by default. You'll see log messages like:
48
+
49
+ ```
50
+ SafetyMailer: Processing 3 recipient(s) - 2 allowed, 1 suppressed
51
+ SafetyMailer: Allowed delivery for user@mydomain.com
52
+ SafetyMailer: Suppressed delivery for user@external.com (no matching allowed pattern)
53
+ SafetyMailer: Delivering email to 2 allowed recipient(s)
54
+ ```
55
+
56
+ ### Custom Logger Configuration
57
+
58
+ You can specify a custom logger in your configuration:
59
+
60
+ ```ruby
61
+ require 'logger'
62
+
63
+ # Create a custom logger
64
+ safety_logger = Logger.new(Rails.root.join('log', 'safety_mailer.log'))
65
+
66
+ config.action_mailer.delivery_method = :safety_mailer
67
+ config.action_mailer.safety_mailer_settings = {
68
+ allowed_matchers: [ /mydomain.com/, /mytestacct@gmail.com/ ],
69
+ logger: safety_logger, # Custom logger
70
+ delivery_method: :smtp,
71
+ # ... other settings
72
+ }
73
+ ```
74
+
75
+ ### Disabling Logging
76
+
77
+ To disable logging entirely, set the logger to `nil`:
78
+
79
+ ```ruby
80
+ config.action_mailer.safety_mailer_settings = {
81
+ allowed_matchers: [ /mydomain.com/ ],
82
+ logger: nil, # Disable all logging
83
+ delivery_method: :smtp,
84
+ # ... other settings
85
+ }
86
+ ```
87
+
88
+ ### Non-Rails Applications
89
+
90
+ For non-Rails applications, SafetyMailer remains silent by default. You can enable logging by providing a custom logger:
91
+
92
+ ```ruby
93
+ require "safety_mailer"
94
+ require "logger"
95
+
96
+ # Configure with custom logger
97
+ custom_logger = Logger.new(STDOUT)
98
+
99
+ Mail.defaults do
100
+ delivery_method SafetyMailer::Carrier, {
101
+ allowed_matchers: [ /mydomain.com/ ],
102
+ logger: custom_logger,
103
+ delivery_method: :smtp
104
+ }
105
+ end
106
+ ```
107
+
108
+ Now, email to `anyone@mydomain.com`, `mytestacct@gmail.com`, `bob+safety_mailer@yahoo.com` all get sent, and email to other recipients (like the real users in the production database you copied to a test server) is suppressed.
109
+
110
+ ## Non-Rails
111
+
112
+ Any user of the Mail gem can configure safety_mailer:
113
+
114
+ ```ruby
115
+ require "safety_mailer"
116
+ Mail.defaults do
117
+ delivery_method SafetyMailer::Carrier, {
118
+ ... same settings as above
119
+ }
120
+ end
121
+ ```
122
+
123
+ ## Non-Mail
124
+
125
+ If you're not using the Mail gem (or use it sometimes but want to use the same logic / configuration in other contexts), you can filter directly:
126
+
127
+ ```
128
+ filtered_array = SafetyMailer::Carrier.new(ActionMailer::Base.safety_mailer_settings).filter(unfiltered_email_addresses)
129
+ ```
130
+
131
+ ## Development
132
+
133
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
134
+
135
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
136
+
137
+ ## Contributing
138
+
139
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cluesque/safety_mailer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/cluesque/safety_mailer/blob/main/CODE_OF_CONDUCT.md).
140
+
141
+ ## License
142
+
143
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
144
+
145
+ ## Code of Conduct
146
+
147
+ Everyone interacting in the SafetyMailer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cluesque/safety_mailer/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -1,26 +1,16 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
- require 'rspec/core/rake_task'
4
- Bundler::GemHelper.install_tasks
1
+ # frozen_string_literal: true
5
2
 
6
- task :console do
7
- Rake::Task["build"].invoke
8
- Rake::Task["install"].invoke
9
- puts "Loading development console..."
10
- system("irb -r safety_mailer")
11
- end
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
12
5
 
13
- task :help do
14
- puts "Available rake tasks: "
15
- puts "rake console - Run a IRB console with all enviroment loaded"
16
- puts "rake spec - Run specs"
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb', 'test/*_test.rb']
17
10
  end
18
11
 
19
- task :spec do
20
- desc "Run all specs with rcov"
21
- RSpec::Core::RakeTask.new(:spec) do |t|
22
- t.pattern = "spec/**/*_spec.rb"
23
- end
24
- end
12
+ require 'rubocop/rake_task'
13
+
14
+ RuboCop::RakeTask.new
25
15
 
26
- task :default => [:spec]
16
+ task default: %i[test rubocop]
Binary file
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SafetyMailer
4
+ # Defining a Railtie to hook into Rails initialization process
2
5
  class Railtie < Rails::Railtie
3
6
  config.before_configuration do
4
7
  ActionMailer::Base.add_delivery_method :safety_mailer, SafetyMailer::Carrier
@@ -1,27 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
1
5
  module SafetyMailer
6
+ # Carrier class implements a delivery method for ActionMailer
2
7
  class Carrier
3
- attr_accessor :matchers, :settings, :mail
8
+ attr_accessor :matchers, :settings, :mail, :logger
4
9
 
5
10
  def initialize(params = {})
6
11
  self.matchers = params[:allowed_matchers] || []
7
12
  self.settings = params[:delivery_method_settings] || {}
8
- delivery_method = params[:delivery_method] || :smtp
9
- @delivery_method = ActionMailer::Base.delivery_methods[delivery_method].new(settings)
13
+ self.logger = determine_logger(params[:logger])
14
+ delivery_method_name = params[:delivery_method] || :smtp
15
+ @delivery_method = if defined?(ActionMailer)
16
+ ActionMailer::Base.delivery_methods[delivery_method_name].new(settings)
17
+ else
18
+ Mail::Configuration.instance.lookup_delivery_method(delivery_method_name).new(settings)
19
+ end
10
20
  @sendgrid_options = {}
11
21
  end
12
22
 
13
23
  def deliver!(mail)
14
24
  self.mail = mail
15
- allowed = filter(recipients)
25
+ original_recipients = recipients
26
+ allowed = filter(original_recipients)
27
+
28
+ log_delivery_summary(original_recipients, allowed)
16
29
 
17
30
  if allowed.empty?
18
- log "*** safety_mailer - no allowed recipients ... suppressing delivery altogether"
31
+ log 'SafetyMailer: No allowed recipients found - suppressing delivery altogether'
19
32
  return
20
33
  end
21
34
 
22
- mail['X-SMTPAPI'].value = prepare_sendgrid_delivery(allowed) if sendgrid?
35
+ if sendgrid?
36
+ sendgrid_header = prepare_sendgrid_delivery(allowed)
37
+ mail.header.fields.delete_if { |f| f.name =~ /X-SMTPAPI/i }
38
+ mail['X-SMTPAPI'] = sendgrid_header
39
+ log 'SafetyMailer: Updated SendGrid header with filtered recipients'
40
+ end
23
41
  mail.to = allowed
24
42
 
43
+ log "SafetyMailer: Delivering email to #{allowed.size} allowed recipient(s)"
25
44
  @delivery_method.deliver!(mail)
26
45
  end
27
46
 
@@ -29,7 +48,18 @@ module SafetyMailer
29
48
  matchers.any? { |m| recipient =~ m }
30
49
  end
31
50
 
32
- private
51
+ def filter(addresses)
52
+ return [] if addresses.nil? || addresses.empty?
53
+
54
+ allowed, rejected = addresses.partition { |r| whitelisted?(r) }
55
+
56
+ rejected.each { |addr| log "SafetyMailer: Suppressed delivery for #{addr} (no matching allowed pattern)" }
57
+ allowed.each { |addr| log "SafetyMailer: Allowed delivery for #{addr}" }
58
+
59
+ allowed
60
+ end
61
+
62
+ private
33
63
 
34
64
  def recipients
35
65
  sendgrid?
@@ -39,19 +69,11 @@ module SafetyMailer
39
69
 
40
70
  def sendgrid?
41
71
  @sendgrid ||= !!if mail['X-SMTPAPI']
42
- @sendgrid_options = JSON.parse(mail['X-SMTPAPI'].value)
43
- end
72
+ @sendgrid_options = JSON.parse(mail['X-SMTPAPI'].value)
73
+ end
44
74
  rescue JSON::ParserError
45
- log "*** safety_mailer was unable to parse the X-SMTPAPI header"
46
- end
47
-
48
- def filter(addresses)
49
- allowed, rejected = addresses.partition { |r| whitelisted?(r) }
50
-
51
- rejected.each { |addr| log "*** safety_mailer delivery suppressed for #{addr}" }
52
- allowed.each { |addr| log "*** safety_mailer delivery allowed for #{addr}" }
53
-
54
- allowed
75
+ log 'SafetyMailer: Unable to parse X-SMTPAPI header - invalid JSON format'
76
+ false
55
77
  end
56
78
 
57
79
  # Handles clean-up for additional SendGrid features that may be required
@@ -67,12 +89,11 @@ module SafetyMailer
67
89
  # whitelisted addresses.
68
90
  #
69
91
  # @see http://docs.sendgrid.com/documentation/api/smtp-api/developers-guide/substitution-tags/
70
- if substitutions = @sendgrid_options['sub']
92
+ if (substitutions = @sendgrid_options['sub'])
71
93
  substitutions.each do |template, values|
72
94
  values = recipients.zip(values).map do |addr, value|
73
95
  value if addresses.include?(addr)
74
96
  end
75
-
76
97
  substitutions[template] = values.compact
77
98
  end
78
99
 
@@ -83,8 +104,26 @@ module SafetyMailer
83
104
  end
84
105
 
85
106
  def log(msg)
86
- Rails.logger.warn(msg) if defined?(Rails)
107
+ return unless logger
108
+
109
+ logger.warn(msg)
110
+ end
111
+
112
+ def determine_logger(custom_logger)
113
+ return custom_logger if custom_logger
114
+ return Rails.logger if defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger
115
+
116
+ nil
87
117
  end
88
118
 
119
+ def log_delivery_summary(original_recipients, allowed_recipients)
120
+ return unless logger
121
+
122
+ total = original_recipients.size
123
+ allowed = allowed_recipients.size
124
+ suppressed = total - allowed
125
+
126
+ log "SafetyMailer: Processing #{total} recipient(s) - #{allowed} allowed, #{suppressed} suppressed"
127
+ end
89
128
  end
90
129
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SafetyMailer
2
- VERSION = '0.0.9'
3
- end
4
+ VERSION = '0.1.0'
5
+ end
data/lib/safety_mailer.rb CHANGED
@@ -1,3 +1,5 @@
1
- require "safety_mailer/safety_mailer"
2
- require "safety_mailer/version"
3
- require "safety_mailer/railtie" if defined? Rails
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'safety_mailer/version'
4
+ require_relative 'safety_mailer/safety_mailer'
5
+ require_relative 'safety_mailer/railtie' if defined? Rails
@@ -0,0 +1,4 @@
1
+ module SafetyMailer
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata CHANGED
@@ -1,107 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safety_mailer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Kirtley
8
- autorequire:
9
- bindir: bin
8
+ bindir: exe
10
9
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rspec
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: mail
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '>='
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: actionmailer
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description: Specify a domain (or set of domains, or magic word in email address)
70
- email is allowed to go to, and email to all other domains is silently dropped. Useful
71
- for testing and staging environments.
72
- email: bill.kirtley@gmail.com
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Restrict email sent by your application. Useful for testing and staging
13
+ environments.
14
+ email:
15
+ - bill.kirtley@gmail.com
73
16
  executables: []
74
17
  extensions: []
75
18
  extra_rdoc_files: []
76
19
  files:
77
- - Gemfile
78
- - README.rdoc
20
+ - ".rubocop.yml"
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - LICENSE.txt
24
+ - README.md
79
25
  - Rakefile
26
+ - assets/logo_ruby_hardhat.png
80
27
  - lib/safety_mailer.rb
81
28
  - lib/safety_mailer/railtie.rb
82
29
  - lib/safety_mailer/safety_mailer.rb
83
30
  - lib/safety_mailer/version.rb
31
+ - sig/safety_mailer.rbs
84
32
  homepage: http://github.com/cluesque/safety_mailer
85
- licenses: []
86
- metadata: {}
87
- post_install_message:
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: http://github.com/cluesque/safety_mailer
37
+ source_code_uri: http://github.com/cluesque/safety_mailer
38
+ changelog_uri: http://github.com/cluesque/safety_mailer/blob/master/CHANGELOG.md
39
+ rubygems_mfa_required: 'true'
88
40
  rdoc_options: []
89
41
  require_paths:
90
42
  - lib
91
43
  required_ruby_version: !ruby/object:Gem::Requirement
92
44
  requirements:
93
- - - '>='
45
+ - - ">="
94
46
  - !ruby/object:Gem::Version
95
- version: '0'
47
+ version: 2.7.5
96
48
  required_rubygems_version: !ruby/object:Gem::Requirement
97
49
  requirements:
98
- - - '>='
50
+ - - ">="
99
51
  - !ruby/object:Gem::Version
100
52
  version: '0'
101
53
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.4.2
104
- signing_key:
54
+ rubygems_version: 3.6.9
105
55
  specification_version: 4
106
56
  summary: Restrict email sent by your application to only approved domains or accounts.
107
57
  test_files: []
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in safety_mailer.gemspec
4
- gemspec
data/README.rdoc DELETED
@@ -1,53 +0,0 @@
1
- == safety_mailer
2
-
3
- Restrict email sent by your application to only approved domains or accounts.
4
-
5
- Specify a domain (or set of domains, or magic word in email address) email is allowed to go to, and email to all other domains is silently dropped.
6
-
7
- This is useful for testing or staging environments where you want to be certain email to real customers doesn't escape the lab.
8
-
9
- Layered on the Mail gem, so Rails >= 3.0 applications can use safety_mailer.
10
-
11
- == Rails >= 3.0
12
-
13
- Add the gem to your +Gemfile+, specifying groups (probably not production) to include it in.
14
-
15
- gem "safety_mailer", :group => :development
16
-
17
- Don't forget to <tt>bundle install</tt> to install
18
-
19
- In your environment file <tt>config/environments/development.rb</tt> configure it, and some regular expressions.
20
-
21
- config.action_mailer.delivery_method = :safety_mailer
22
- config.action_mailer.safety_mailer_settings = {
23
- allowed_matchers: [ /mydomain.com/, /mytestacct@gmail.com/, /super_secret_test/ ],
24
- delivery_method: :smtp,
25
- delivery_method_settings: {
26
- :address => "smtp.mydomain.com",
27
- :port => 25,
28
- :domain => "mydomain.com",
29
- :authentication => :plain,
30
- :user_name => "mydomain_mailer@mydomain.com",
31
- :password => "password"
32
- }
33
- }
34
-
35
- ... and now, email to anyone@mydomain.com, mytestacct@gmail.com, bob+super_secret_test@yahoo.com all get sent
36
- and email to other recipients (like the real users in the production database you copied to a test server) is suppressed.
37
-
38
- == Non-Rails
39
-
40
- Any user of the Mail gem can configure safety_mailer:
41
-
42
- require "safety_mailer"
43
- Mail.defaults do
44
- delivery_method SafetyMailer::Carrier, {
45
- ... same settings as above
46
- }
47
- end
48
-
49
- == License
50
-
51
- safety_mailer is released under the MIT license:
52
-
53
- * http://www.opensource.org/licenses/MIT