Add a feature to allow emails to specific domains only.
Closed this issue · 4 comments
pboling commented
Similar to: osbornebrook@dda1f9b#commitcomment-4703742
milgner commented
FWIW, we implemented this with activation_proc
for the time being:
config[:activation_proc] = ->(message) do
Array(message.to).any? { |recipient| Mail::Address.new(recipient).domain != 'example.com' }
end
pboling commented
Thanks for the example!
pboling commented
Your example prevents sending the email if any of the recipients do not have a specific domain.
So, that's logically the same as do all of the recipients have a given domain, except your version is faster...
I'll add the README!
pboling commented
Oh, but your version is missing a !
.
%w(
me@example.com
you@example.net
us@example.net
).any? { |email| email.domain != "example.com" }
# => true, means it will send the email
Your example is the opposite of what you want I think.