Module: SanitizeEmail
- Extended by:
- Deprecation
- Defined in:
- lib/sanitize_email/bleach.rb,
lib/sanitize_email.rb,
lib/sanitize_email/config.rb,
lib/sanitize_email/railtie.rb,
lib/sanitize_email/version.rb,
lib/sanitize_email/mail_ext.rb,
lib/sanitize_email/engine_v5.rb,
lib/sanitize_email/engine_v6.rb,
lib/sanitize_email/deprecation.rb,
lib/sanitize_email/test_helpers.rb,
lib/sanitize_email/rspec_matchers.rb,
lib/sanitize_email/mail_header_tools.rb,
lib/sanitize_email/overridden_addresses.rb
Overview
Copyright © 2008 - 2018, 2020, 2022, 2024 Peter H. Boling of RailsBling.com Released under the MIT license
Defined Under Namespace
Modules: Deprecation, MailExt, MailHeaderTools, RspecMatchers, TestHelpers, Version Classes: Bleach, Config, EngineV5, EngineV6, MissingBlockParameter, OverriddenAddresses, Railtie
Constant Summary collapse
Constants included from Deprecation
Deprecation::DEPRECATE_IN_SILENCE_MUTEX
Class Method Summary collapse
- .[](key) ⇒ Object
- .activate?(message) ⇒ Boolean
- .force_sanitize ⇒ Object
- .force_sanitize=(value) ⇒ Object
- .janitor(options) ⇒ Object
-
.local_environments ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing.
- .method_missing(name, *_args) ⇒ Object
- .respond_to_missing?(method_name, include_private = false) ⇒ Boolean
-
.sanitary(config_options = {}) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to send sanitary email in any environment.
-
.sanitized_recipients ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing.
-
.unsanitary ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to force unsanitary email in any environment.
Methods included from Deprecation
deprecate_in_silence, deprecate_in_silence=, deprecated, deprecated_alias, deprecation, deprecation_warning_message
Class Method Details
.[](key) ⇒ Object
69 70 71 72 |
# File 'lib/sanitize_email.rb', line 69 def [](key) return unless key.respond_to?(:to_sym) SanitizeEmail::Config.config[key.to_sym] end |
.activate?(message) ⇒ Boolean
98 99 100 101 |
# File 'lib/sanitize_email.rb', line 98 def activate?() proc = SanitizeEmail::Config.config[:activation_proc] proc.call() if proc.respond_to?(:call) end |
.force_sanitize ⇒ Object
61 62 63 |
# File 'lib/sanitize_email.rb', line 61 def force_sanitize FORCE_SANITIZE_MUTEX.synchronize { @force_sanitize } end |
.force_sanitize=(value) ⇒ Object
65 66 67 |
# File 'lib/sanitize_email.rb', line 65 def force_sanitize=(value) FORCE_SANITIZE_MUTEX.synchronize { @force_sanitize = value } end |
.janitor(options) ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/sanitize_email.rb', line 147 def janitor() raise MissingBlockParameter, "SanitizeEmail.janitor must be called with a block" unless block_given? original = SanitizeEmail.force_sanitize SanitizeEmail.force_sanitize = [:forcing] yield SanitizeEmail.force_sanitize = original end |
.local_environments ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing
94 95 96 |
# File 'lib/sanitize_email.rb', line 94 def local_environments SanitizeEmail::Config.config[:local_environments] end |
.method_missing(name, *_args) ⇒ Object
74 75 76 77 78 79 80 |
# File 'lib/sanitize_email.rb', line 74 def method_missing(name, *_args) if name SanitizeEmail[name] else super end end |
.respond_to_missing?(method_name, include_private = false) ⇒ Boolean
82 83 84 |
# File 'lib/sanitize_email.rb', line 82 def respond_to_missing?(method_name, include_private = false) method_name ? method_name : super end |
.sanitary(config_options = {}) ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to send sanitary email in any environment. You have access to all the same configuration options in the parameter hash as you can set in the actual SanitizeEmail.configure block.
SanitizeEmail.sanitary(sanitized_to: “boo@example.com”) do
Mail.deliver do
from "from@example.org"
# Will actually be sent to the override addresses, not this one:
to "to@example.org"
reply_to "reply_to@example.org"
subject "subject"
end
end
118 119 120 121 122 123 124 125 126 |
# File 'lib/sanitize_email.rb', line 118 def sanitary( = {}) raise MissingBlockParameter, "SanitizeEmail.sanitary must be called with a block" unless block_given? janitor(forcing: true) do original = SanitizeEmail::Config.config.dup SanitizeEmail::Config.config.merge!() yield SanitizeEmail::Config.config = original end end |
.sanitized_recipients ⇒ Object
NOTE: Deprecated method We have to actually define because we can’t deprecate methods that are hooked up via method_missing
88 89 90 |
# File 'lib/sanitize_email.rb', line 88 def sanitized_recipients # NOOP - This method is never actually executed, because the deprecations redirects the call to sanitized_to end |
.unsanitary ⇒ Object
Regardless of the Config settings of SanitizeEmail you can do a local override to force unsanitary email in any environment.
SanitizeEmail.unsanitary do
Mail.deliver do
from "from@example.org"
to "to@example.org"
reply_to "reply_to@example.org"
subject "subject"
end
end
140 141 142 143 144 145 |
# File 'lib/sanitize_email.rb', line 140 def unsanitary raise MissingBlockParameter, "SanitizeEmail.unsanitary must be called with a block" unless block_given? janitor(forcing: false) do yield end end |