Last active
December 11, 2015 21:48
-
-
Save pbyrne/4665235 to your computer and use it in GitHub Desktop.
Sample interceptor to interrupt outbound emails in non-production environments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in lib or a gem or something | |
class NonProductionInterceptor | |
def self.delivering_email(message) | |
# implement some mechanism to strip non-example.com and non-tstmedia.com email | |
# addresses from the delivery lists. also verify that if no delivery emails are | |
# left, either drop the email (if possible) or add [email protected] or some | |
# other dummy address so no exception is raised when attempting to deliver. | |
# | |
# Feel free to crib from TstMailer, of course. | |
# | |
# Also, this example seems to be a good fit: http://renderedtext.com/blog/2012/04/27/filtering-emails-on-staging/ | |
end | |
end | |
# put this in an initializer | |
Mail.register_interceptor(NonProductionInterceptor) unless Rails.env.production? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment