From b18b9197cff81d59bf286331b0782fb4e09b5f90 Mon Sep 17 00:00:00 2001 From: Matt Kobs Date: Mon, 12 Jan 2026 10:57:24 -0600 Subject: [PATCH 1/2] [skip] Added .DS_Store to gitignore (1m) --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5ba2c65..cbd1d9e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ test/dummy/db/*.sqlite3-journal test/dummy/log/*.log test/dummy/tmp/ test/dummy/.sass-cache +**/.DS_Store From 8aaa1408b4a97af66ddc8af99ef632bcc7f1950d Mon Sep 17 00:00:00 2001 From: Matt Kobs Date: Mon, 12 Jan 2026 10:57:24 -0600 Subject: [PATCH 2/2] [improvement] Added configuration option for ignoring bounce notifications for certain emails (10m) Should hopefully prevent us from trying to send bounce notifications back to `automail@360members.com` address. --- app/mailers/ep_postmaster/postmaster.rb | 5 ++++- lib/ep_postmaster/configuration.rb | 3 ++- mise.toml | 2 ++ test/unit/mailers/ep_postmaster/postmaster_test.rb | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 mise.toml diff --git a/app/mailers/ep_postmaster/postmaster.rb b/app/mailers/ep_postmaster/postmaster.rb index 09b32af..507c2cc 100644 --- a/app/mailers/ep_postmaster/postmaster.rb +++ b/app/mailers/ep_postmaster/postmaster.rb @@ -2,7 +2,10 @@ module EpPostmaster class Postmaster < ::ActionMailer::Base def bounced_email(options = {}) - @to = MailgunPost.unfurl(options.fetch(:original_sender) { options.fetch(:reply_to) }) + @to = Array.wrap(MailgunPost.unfurl(options.fetch(:original_sender) { options.fetch(:reply_to) })) + @to -= EpPostmaster.configuration.ignored_bounce_emails + return if @to.empty? + @recipient = options.fetch(:original_recipient) @subject = options[:original_subject] @error = options[:error] diff --git a/lib/ep_postmaster/configuration.rb b/lib/ep_postmaster/configuration.rb index 29b6133..87da464 100644 --- a/lib/ep_postmaster/configuration.rb +++ b/lib/ep_postmaster/configuration.rb @@ -1,9 +1,10 @@ module EpPostmaster class Configuration - attr_accessor :mailgun_api_key, :mailer_sender, :mailer_deliverer + attr_accessor :mailgun_api_key, :mailer_sender, :mailer_deliverer, :ignored_bounce_emails def initialize @mailgun_api_key = "" + @ignored_bounce_emails = [] self.mailer_deliverer = ->(message) { message.deliver_now } self.bounced_email_handler = Class.new do def self.handle_bounced_email!(*) diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..becf770 --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +ruby = "3.4" diff --git a/test/unit/mailers/ep_postmaster/postmaster_test.rb b/test/unit/mailers/ep_postmaster/postmaster_test.rb index 3881dab..675bb3e 100644 --- a/test/unit/mailers/ep_postmaster/postmaster_test.rb +++ b/test/unit/mailers/ep_postmaster/postmaster_test.rb @@ -40,6 +40,15 @@ class PostmasterTest < ActionMailer::TestCase should "say something in the body of the email" do assert_match "unable to deliver", mail.body.encoded end + + should "not send anything when the original sender is in a list of ignored addresses" do + EpPostmaster.configure { |config| config.ignored_bounce_emails = [ "sender@test.test" ] } + message = Postmaster.bounced_email(options).message + EpPostmaster.configure { |config| config.ignored_bounce_emails = [] } + + assert message.is_a?(ActionMailer::Base::NullMail) + + end end private