[ad_1]
I would like to send an email if the user has send_mail preferences settings true.
Interceptor looks good for this. It works for localhost and testing env.
class TestingEmailInterceptor
def self.delivering_email(message)
message.to = message.to.map { |email| "test+#{email.split('@').first}@gmail.com" }
end
end
The interceptor adds test words for emails. Like this: [email protected]
I would like to create two new interceptors. If users have send_mail preferences, I will send an email to them.
I don’t want to lose that interceptor setting. Rails initialized the interceptor like this.
if Rails.env.development?
ActionMailer::Base.register_interceptor(TestingEmailInterceptor)
end
I want to create two interceptors for production env. I have Store and Company models and they have relations with the User model.
What is the best practice for this?
[ad_2]