Last active
January 27, 2017 13:03
-
-
Save lcguida/db303d87a1b1afeff02b7dcf636a5887 to your computer and use it in GitHub Desktop.
Custom delivery method to replace recipient on sendmail for a staging environment
This file contains hidden or 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
# lib/utils/sendmail_staging.rb | |
class SendmailStaging < ::Mail::Sendmail | |
# mail object can be used to modify mail before we pass it | |
# to sendmail | |
def deliver!(mail) | |
mail['to'] = '[email protected]' #replace recipient | |
super(mail) #Let Sendmail do his work | |
end | |
end |
This file contains hidden or 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
# config/initializers/sendmail_staging_delivery_method.rb | |
# Register the custom delivery method: | |
ActionMailer::Base.add_delivery_method :sendmail_staging, SendmailStaging |
This file contains hidden or 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
# config/environment/staging.rb | |
Rails.application.configure do | |
# ... other configs ... | |
config.action_mailer.delivery_method = :sendmail_staging | |
# ... other configs ... | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment