Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:58:27+00:00 2026-05-29T08:58:27+00:00

We want to test email functionality on our staging server, but we don’t want

  • 0

We want to test email functionality on our staging server, but we don’t want to accidentally email customers.

So, I’d like emails sent to “anything@corporation.com” to work, but emails sent to “anything@customer.com” to be suppressed.

I could just go into all of my controllers and put in code that only fires the “deliver” method if the email contains our domain or the environment is prod. But, that seems kinda kludgey. I’d like to do it app wide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:58:27+00:00Added an answer on May 29, 2026 at 8:58 am

    Applications that use the Mail gem (including rails >= 3.0 projects) can use the safety_mailer gem. Specify a domain (or set of domains, or magic word in email address) email is allowed to go to, and email to all other domains is silently dropped.

    https://github.com/cluesque/safety_mailer

    Add the gem to your Gemfile, specifying groups (probably not production) to include it in.

    gem "safety_mailer", :group => :development
    

    Don’t forget to bundle install to install

    In your environment file config/environments/development.rb configure it, and some regular expressions.

    config.action_mailer.delivery_method = :safety_mailer
    SafetyMailer::Config.allowed_matchers = [ /mydomain.com/, /mytestacct@gmail.com/, /super_secret_test/ ]
    

    … and now, email to anyone@mydomain.com, mytestacct@gmail.com, bob+super_secret_test@yahoo.com all get sent
    and email to other recipients (like the real users in the production database you copied to a test server) is suppressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to test a Java code for sending email. I don't want to
We want test the JTAPI feature of our application. Are there any emulator for
I want test a FIX gateway for our company and was wondering if anything
I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is
I want to unit test a Java application that fetches mails from an email
I want to use ms sql 2005 to send email reminders to my customers.
I am sending emails successfully using following code. But now I want to attach
I have an email address enclosed in single quotes: $email = 'test@email.com'; I want
I want to send notification on Yammer through Ant, but no notification are sent.
i want to send some html in email body, but gmail doesn't interpret iframe

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.