Skip to content

Instantly share code, notes, and snippets.

@henrik
Created March 6, 2009 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henrik/74903 to your computer and use it in GitHub Desktop.
Save henrik/74903 to your computer and use it in GitHub Desktop.
Cancel mail from within an ActionMailer deliver_* method.
# Allow cancelling mails from within an ActionMailer deliver_* method by doing "raise NotSendingMail".
# In an ApplicationMailer that other mailers inherit from:
class NotSendingMail < StandardError; end
def self.method_missing(*args)
super
rescue NotSendingMail => e
Rails.logger.info("Not mailing! #{e}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment