How to catch error exception in ActionMailer

前端 未结 5 819
误落风尘
误落风尘 2020-12-05 00:58

The problem is how can I catch exception in delivering mail by ActionMailer. For me it sounds impossible, because in this case ActionMailer should sent mail to mailserver, a

5条回答
  •  鱼传尺愫
    2020-12-05 01:38

    class ApplicationMailer < ActionMailer::Base
      rescue_from [ExceptionThatShouldBeRescued] do |exception|
        #handle it here
      end
    end
    

    Works with rails 5 onwards. And it's the best practice.

提交回复
热议问题