'Rails action Mailer raise_delivery_errors, how does it works? How to detect bounces?
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?
Solution 1:[1]
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
.
Solution 2:[2]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Dorian |