Rails action Mailer raise_delivery_errors, how does it works? How to detect bounces?
Asked Answered
I

2

8

I have a Rails 4.2.0 application which sends lots of mails, it's a elearning platfrom.

At the moment I have problems with bounces, Lots of the Mails coming back because the Mail-Adresses aren't valid.

One way is to solve the problem manually, starting deleting them from Database. But thats not suitable because there are about 10000 Users registered.

Now my questsion is what is

config.action_mailer.raise_delivery_errors = true 

exactly? what does it do? and how do I get response from this?

Does the mail() method got a return value where I can see If a mail was send or not?

And are there methods or best practices to detect with the actionmailer, if a mail is delivered or not?

Isooctane answered 12/5, 2015 at 9:12 Comment(0)
G
11

If set to false, mail will silently catch and ignore any exceptions raised through attempting to deliver an email. Reference.

In production it is good to set it to false, because otherwise failed email will throw an error to your end user.

In development definitely set it to true.

Take a look at this gem.

Among other features there is a method specifically to check if mail was bounced.

Gracious answered 12/5, 2015 at 9:24 Comment(2)
I run the mailings with cronjobs where are the errors shown then? Ind are there other ways to detect bounces?Isooctane
By the way, today, Rails Action Mailer uses the Mail gem, the bounced? method is available in Rails.Spiker
S
1

In my experience it's better to set it to true in production because you should send your emails in background jobs and sending the email will be retried if an error is raised.

  # Ignore bad email addresses and do not raise email delivery errors.
  # Set this to true and configure the email server for immediate delivery to raise delivery errors.
  # config.action_mailer.raise_delivery_errors = false

And set it to false in development as the initial rails setup says, you Don't care if the mailer can't send.

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

From rails new b in Rails 7.0.2.3

Sweeten answered 23/4, 2022 at 14:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.