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 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

rails-bot commented Jun 15, 2017

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.

@halogenandtoast halogenandtoast force-pushed the halogenandtoast:mm-configure_delivery_job branch 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
@halogenandtoast halogenandtoast force-pushed the halogenandtoast:mm-configure_delivery_job branch to d9bbde0 Jun 15, 2017
@halogenandtoast
Copy link
Contributor Author

halogenandtoast commented Jun 15, 2017

I believe the CI failure is unrelated to my changes.

Copy link
Member

guilleiguaran left a comment

👍

@guilleiguaran guilleiguaran merged commit 95ae033 into rails:master Jun 15, 2017
2 checks passed
2 checks passed
codeclimate no new or fixed issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
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

eftikharEmad commented Aug 6, 2018

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

halogenandtoast commented Aug 6, 2018

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

@jerryskye
Copy link

jerryskye commented Mar 6, 2019

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
Member

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants
You can’t perform that action at this time.