Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if Rails action mailer deliver fails?

In my project, I'm using Rails 4.1.1 and Ruby 2.1.1. I was reading the mail gem, but wasn't sure how to check if the deliver failed (for any reason).

result = UserMailer.signup.deliver
if result.action == 'failed' or result.bounced?
    # How can you tell if a deliver has failed?
    # Do stuff here if failed
end
like image 206
Derek Avatar asked Jun 01 '14 07:06

Derek


1 Answers

As described in http://guides.rubyonrails.org/action_mailer_basics.html, you can set

config.action_mailer.raise_delivery_errors = true

this way, Rails will raise an error in case the delivery can't take place

like image 59
Danny Avatar answered Nov 12 '22 06:11

Danny