aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2018-09-27 16:44:41 -0700
committerDavid Heinemeier Hansson <david@loudthinking.com>2018-09-27 16:44:41 -0700
commitb25948bd5092026ae70b88954acbb11b133c889c (patch)
treedb34236cbb91b1b7a02528ac4fff3d6e192b1f6b
parentb190f0fa65b2633f96b352bb1975cd1ce379b972 (diff)
downloadrails-b25948bd5092026ae70b88954acbb11b133c889c.tar.gz
rails-b25948bd5092026ae70b88954acbb11b133c889c.tar.bz2
rails-b25948bd5092026ae70b88954acbb11b133c889c.zip
Make an email that fails to deliver to a mailbox as bounced
Probably need a way to either provide more email on the nature of a bounce or have a separate status code for "undeliverable".
-rw-r--r--lib/action_mailroom/router.rb2
-rw-r--r--test/unit/router_test.rb1
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/action_mailroom/router.rb b/lib/action_mailroom/router.rb
index fb0b638978..29ba803e03 100644
--- a/lib/action_mailroom/router.rb
+++ b/lib/action_mailroom/router.rb
@@ -19,6 +19,8 @@ class ActionMailroom::Router
if mailbox = match_to_mailbox(inbound_email)
mailbox.receive(inbound_email)
else
+ inbound_email.bounced!
+
raise RoutingError
end
end
diff --git a/test/unit/router_test.rb b/test/unit/router_test.rb
index 75701b669e..678810a900 100644
--- a/test/unit/router_test.rb
+++ b/test/unit/router_test.rb
@@ -85,6 +85,7 @@ module ActionMailroom
assert_raises(ActionMailroom::Router::RoutingError) do
inbound_email = create_inbound_email_from_mail(to: "going-nowhere@example.com", subject: "This is a reply")
@router.route inbound_email
+ assert inbound_email.bounced?
end
end