pboling/sanitize_email

Add a feature to allow emails to specific domains only.

Closed this issue · 4 comments

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

Thanks for the example!

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!

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.