We have an application built in rails 3.2.8. We are sending emails to customers. I want to block certain emails addressses. Basically mailer just ignore those particular email addresses.
For example: My company name is abc and I dont want to send emails to all my employees ie [email protected] or [email protected] ie *@abc.com
How can I do this?
PS: I am using sendgrid, they are not providing anything like this.
EDIT:
Placing this code in initializers directory:
class EmailAddressFilter
def self.delivering_email(message)
message.perform_deliveries = false
end
end
ActionMailer::Base.register_interceptor(EmailAddressFilter)
Should block all the emails. But still I can see emails in my development log.
PS: I have restarted my server.
In a file in config/initializers you can add something like this
class EmailAddressFilter
def self.delivering_email(message)
# permit or deny the message using its "to", "body" etc properties
# note message.to is an array (multiple emails)
message.perform_deliveries = Email.whitelisted?(message.to)
end
end
ActionMailer::Base.register_interceptor(EmailAddressFilter)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With