Reputation: 8568
What is the standard way or configuration option for Rails 5 application to retry sending an email if it raises an exception during sending the email?
I expect some option to retry sending a number of times but couldn't find anything like that.
More details:
I got this error while sending an important email, it happened only once since months but that is an important email, so I would like to increase reliability of sending the emails by retrying if some exception happens (like network issue or my smtp provider couldn't receive my email or any similar reason)
451 Authentication failed: Could not authenticate
Upvotes: 2
Views: 1130
Reputation: 998
I'd recommend to use delayed_job gem for the purpose.
When you want to send an email you would need to call delay
method.
Mailer.delay.your_method
it will create a record in database that will be executed in background.
If a background job fails, the error will be saved for the row. You can configure MAX_ATTEMPTS number for delayed_job server. If no errors while sending - record will be deleted from the delayed_jobs
table.
Upvotes: 1