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

How to fix "Sending mail with DeliveryJob and Parameterized::DeliveryJob is deprecated" deprecation? #37068

Closed
everton opened this issue Aug 28, 2019 · 5 comments

Comments

@everton
Copy link

everton commented Aug 28, 2019

Steps to reproduce

Upgrading from Rails 5 to 6 an application which has calls to deliver_later method.

I changed the old style of passing formal parameters to the new one using with and calling params inside the mailer; I have removed the queue parameter which I was using previously in some of the deliver_later calls.

All my mailers inherit from ApplicationMailer which inherits from ActionMailer::Base, there is nothing special from what I'm able to figure out.

There is nothing special I can recall in my configurations about mailers.

Expected behavior

No warnings or an explanation about what to do, since I was not able to figure out what I'm supposed to do to fix this and be prepared to 6.1

Actual behavior

All calls to deliver_later present the warning:

Sending mail with DeliveryJob and Parameterized::DeliveryJob
is deprecated and will be removed in Rails 6.1.
Please use MailDeliveryJob instead.

But I'm not using directly DeliveryJob! I got the warnings in all my tests (models, controllers, integration), both from direct calls in controllers and also from inside other jobs.

System configuration

Rails 6.0.0:

Ruby 2.6.3p62:

@louim
Copy link
Contributor

louim commented Aug 28, 2019

Have you set the config.load_defaults 6.0 in your application.rb file? See https://edgeguides.rubyonrails.org/configuring.html#with-6-0. That should set config.action_mailer.delivery_job: "ActionMailer::MailDeliveryJob". Check that it is correctly set.

@everton
Copy link
Author

everton commented Aug 28, 2019

Thank you @louim, this has removed all the warnings.

@everton everton closed this as completed Aug 28, 2019
@fschwahn
Copy link
Contributor

Just as a heads up for other people running into this while upgrading: it doesn't seem to work to uncomment the relevant line in the generated new_framework_defaults_6_0.rb file. My guess is that it's too late, and mailers from gems are already loaded at that point (in my case devise). Putting the line in application.rb worked though.

Might also be something peculiar about my app.

TobyRet added a commit to DFE-Digital/publish-teacher-training that referenced this issue Mar 18, 2020
- Deprecation warning raised when sending mail - "Sending mail with
DeliveryJob and Parameterized::DeliveryJob is deprecated"
- Fix rails/rails#37068
TobyRet added a commit to DFE-Digital/publish-teacher-training that referenced this issue Mar 18, 2020
- Deprecation warning raised when sending mail - "Sending mail with
DeliveryJob and Parameterized::DeliveryJob is deprecated"
- Fix rails/rails#37068
TobyRet added a commit to DFE-Digital/publish-teacher-training that referenced this issue Mar 19, 2020
- Deprecation warning raised when sending mail - "Sending mail with
DeliveryJob and Parameterized::DeliveryJob is deprecated"
- Fix rails/rails#37068
@modullar
Copy link

modullar commented Sep 2, 2021

@louim
That didn't remove the warnings !

@louim
Copy link
Contributor

louim commented Sep 2, 2021

@modullar If you are using config.load_defaults 6.0 in your application.rb, maybe something is overwriting the specific config. If you are relying on uncommenting the line in new_framework_defaults_6_0.rb try to put the line in application.rb instead.

The root of the problem is often that ActionMailer is loaded too early before the setting is applied. This makes ActionMailer use the deprecated class, hence the warning. One other possible cause could be a gem referencing the old class directly. Look if you have gems that send email that were not updated. Hope that helps!

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

No branches or pull requests

4 participants