Set staging environment email to go to a single email address
Set staging environment email to go to a single email address you control in order to not accidentally send production email addresses staging data.
module SingleRecipientSmtp
def self.included(klass)
klass.class_eval do
cattr_accessor :single_recipient_smtp_settings
end
end
def perform_delivery_single_recipient_smtp(mail)
mail.to = single_recipient_smtp_settings[:to]
mail.cc = nil
mail.bcc = nil
perform_delivery_smtp mail
end
end
Update your config/environments/staging.rb:
config.action_mailer.delivery_method = :single_recipient_smtp
ActionMailer::Base.send :include, SingleRecipientSmtp
ActionMailer::Base.single_recipient_smtp_settings = {
:to => 'staging@example.com'
}
Written by Nikita Fedyashev
Related protips
1 Response
An even better way (in my opinion) is to use an interceptor. Check out the "Interceptors" section of the ASCIIcast here: http://railscasts.com/episodes/206-action-mailer-in-rails-3?view=asciicast
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Email
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#