Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 271
Felix Avatar asked May 12 '15 09:05

Felix


People also ask

What is action Mailer in Rails?

Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.

How do you preview Mailer in Rails?

rails generates a mail preview if you use rails g mailer CustomMailer . You will get a file CustomMailerPreview inside spec/mailers/previews folder. Here you can write your method that will call the mailer and it'll generate a preview.


1 Answers

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.

like image 123
Andrey Deineko Avatar answered Sep 29 '22 17:09

Andrey Deineko