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

Support deferred Mailer delivery with deliver_later #5610

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanpdoyle
Copy link

Re-opens #4224

By default, all Devise::Models::Authenticatable-initiated Action Mailer deliveries are transmitted immediately (within the request-response cycle).

Transmitting emails and interacting with any third-party services over SMTP or HTTP risk service outages and other types of network-related failures.

This commit adds support for deferring delivery to be done from an Action Job background worker queue through the deliver_later method.

 # config/initializers/devise.rb
Devise.mailer_delivery_method = :deliver_later

@seanpdoyle seanpdoyle changed the title Support deferred Mailer deliver with deliver_later Support deferred Mailer delivery with deliver_later Jul 26, 2023
@imsinu9
Copy link

imsinu9 commented Aug 24, 2023

@seanpdoyle Do you think we would be able to get this PR merged? Asking this as I am not seeing any activity on this PR.

@seanpdoyle
Copy link
Author

@carlosantoniodasilva could you approve the CI workflow for this PR?

@carlosantoniodasilva
Copy link
Member

@seanpdoyle Approved it, but there are some test failures in main that I've been looking into, due to some recent merges.

No need to worry about those, I hope to get everything green again soon. (I'm off traveling though, so it might take another couple weeks to circle back on it)

As for the change, I've been wanting to make "later" the default for a while, the current way things work aren't great. I'm not sure about that being an option, haven't given it much thought honestly, but could be a way to migrate over to a new default behavior more easily. Thanks for the PR!

Re-opens [heartcombo#4224][]

By default, all `Devise::Models::Authenticatable`-initiated Action
Mailer deliveries are transmitted immediately (within the
request-response cycle).

Transmitting emails and interacting with any third-party services over
SMTP or HTTP risk service outages and other types of network-related
failures.

This commit adds support for deferring delivery to be done from an
Action Job background worker queue through the [deliver_later][] method.

```ruby
 # config/initializers/devise.rb
Devise.mailer_delivery_method = :deliver_later
```

[heartcombo#4224]: heartcombo#4224
[deliver_now]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_now
[deliver_later]: https://edgeapi.rubyonrails.org/classes/ActionMailer/MessageDelivery.html#method-i-deliver_later
@amo13
Copy link

amo13 commented May 31, 2024

I was also looking for this exact option. The implementation looks pretty straight-forward. Can we get this merged?

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

Successfully merging this pull request may close these issues.

4 participants