Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Cancel Delivery Within Interceptor? #114
I'm using a MailInterceptor within Rails 3 along the lines of Ryan Bates' example (http://railscasts.com/episodes/206-action-mailer-in-rails-3), 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).
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.