Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email and domain whitelist options #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thomasklemm
Copy link

@croaky Thanks for this great gem.

This PR adds two options:

  1. Optionally white-list emails:
Mail.register_interceptor RecipientInterceptor.new(
  ENV['EMAIL_RECIPIENTS'],
  email_whitelist: ['[email protected]']
)
  1. Optionally white-list domains:
Mail.register_interceptor RecipientInterceptor.new(
  ENV['EMAIL_RECIPIENTS'],
  domain_whitelist: ['example.com']
)

If one or more of the original recipients match the email white-list or domain white-list, the email's to field will not be overridden. However, non-white-listed emails will be removed from the email's to field.

@chab
Copy link

chab commented Sep 24, 2014

+1, great to whitelist exception's email (ie. when using exception_notification gem). Thanks to both of you for your work.

@DamirSvrtan
Copy link

@croaky - is there any chance on merging this PR?

@kevinwmerritt
Copy link

👍

@croaky
Copy link
Owner

croaky commented Jul 24, 2015

Hi folks. Making sure I understand the use case:

While we could make EMAIL_RECIPIENTS go to [email protected],[email protected],[email protected], the whitelist change is more convenient, less likely to be forgotten by the team if we use example.com in the domain_whitelist?

The email_whitelist is more convenient because we can unset EMAIL_RECIPIENTS and only [email protected] will get the email instead of kevin, dan, and thomas?

@chab
Copy link

chab commented Jul 25, 2015

Hi @croaky,

I'll let others respond about "domain_whitelist". In our case, we only use the "email_whitelist" option.

Here's what we have in our staging.rb:

  Mail.register_interceptor RecipientInterceptor.new(
    '[email protected]', 
    email_whitelist: %w([email protected])
  )

Without this PR, product owner+testers would receive all exceptions emails as well.

Thanks!

@kevinwmerritt
Copy link

@croaky Thanks for the handy library. You understand the use cases correctly. A domain whitelist would be nice so test users on a certain domain could receive email at their own address instead of the catch all.

@mcmire
Copy link

mcmire commented Dec 23, 2016

@croaky Just came across this PR and this interests me. I guess I thought RecipientInterceptor worked like a whitelist this whole time, when it appears that it completely overrides to: for all emails. Unfortunately this means that staging isn't very realistic if you have different mailers that send emails to different people. I'd be curious if you would approve changing the behavior of this gem to act more like a whitelist?

Base automatically changed from master to main February 21, 2021 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants