Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow mailers to configure their delivery job #29457

Merged

Conversation

halogenandtoast
Copy link
Contributor

@halogenandtoast halogenandtoast commented Jun 15, 2017

Setting delivery_job on a mailer class will cause MessageDelivery to use
the specified job instead of ActionMailer::DeliveryJob

class MyMailer < ApplicationMailer
  self.delivery_job = MyCustomDeliveryJob

  ...
end

Summary

In some situations, a user may want to configure the delivery job in order to have
better control over errors (For example, retrying the job when deserialization fails
due to replica databases not being up to date). This adds an option to each mailer
class that can be configured to handle such behavior.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

Setting delivery_job on a mailer class will cause MessageDelivery to use
the specified job instead of ActionMailer::DeliveryJob:

    class MyMailer < ApplicationMailer
      self.delivery_job = MyCustomDeliveryJob

      ...
    end
@halogenandtoast
Copy link
Contributor Author

I believe the CI failure is unrelated to my changes.

Copy link
Member

@guilleiguaran guilleiguaran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@guilleiguaran guilleiguaran merged commit 95ae033 into rails:master Jun 15, 2017
y-yagi added a commit to y-yagi/rails that referenced this pull request Aug 18, 2017
…eued_emails` to filter delivery job

Since rails#29457, delivery job can specified for each mailer.
Added the `:only` option to make helper method usable even when
deliver job is specified.
@eftikharEmad
Copy link

Hello,
I am getting

undefined method `delivery_job=' for UserNotifier:Class
Did you mean?  delivery_method=

is it rails version issue ?

@halogenandtoast
Copy link
Contributor Author

@eftikharEmad this change made it into 5.2.0 so if you're using an earlier version then yes.

@jerryskye
Copy link

Hi! Thanks for this PR @halogenandtoast 😄
Do you think that adding this for parameterized mailers as well would be a good idea?

@kaspth
Copy link
Contributor

kaspth commented Mar 6, 2019

@jerryskye parameterized mailers got inlined, such that this config works for them on Rails 6. See #34367, though we won't backport it as mentioned in #35215

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants