New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancel Delivery Within Interceptor? #114

jonblock opened this Issue Oct 10, 2010 · 5 comments


None yet
6 participants

jonblock commented Oct 10, 2010

I'm using a MailInterceptor within Rails 3 along the lines of Ryan Bates' example (, but adding a step that removes recipients based on an opt-out list. In cases where there are no recipients left after this filtering, I get an error as the deliver! method attempts to complete its task.

Ideally, I'd like to be able to call a blackhole method on the message object (cancel, dump, abort, whatever) from the interceptor, which would set a flag that causes the rest of the delivery attempt to just give up rather than raising the error.

While I believe this would be useful to others, I don't know enough about the underlying code to implement it properly myself. For now, I'm just assigning my unattended sender's mailbox as a placeholder recipient (a cron task purges that mailbox anyway).


This comment has been minimized.

colszowka commented Feb 7, 2011

You could try to set perform_delivery = false on your mail instance inside the interceptor


This comment has been minimized.

jackdempsey commented Jul 29, 2011

I'm in a similar situation. The perform_delivery change feels a bit hackish, but acceptable to me especially if wrapped in something cleaner that abstracts away the details (which could be cleaned up later).

Any thoughts on this @mikel ? I feel like it's a common enough pattern that could use some love.


This comment has been minimized.

killthekitten commented Jun 4, 2012

+1 from me, abort_delivery method could be great feature, since we have mails in project that aren't controlled by us (devise, for example).


This comment has been minimized.

henrik commented Aug 1, 2012

Helpful, thanks! Note that it's message.perform_deliveries = true, not perform_delivery. Wrote a blog post with an example.


This comment has been minimized.


jeremy commented Jan 26, 2013

Setting message.perform_deliveries = false is the way to go, given the design of the interceptors API.

@jeremy jeremy closed this Jan 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment