-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Mailer.deliver_now! and deliver_later!
What changed? ============= We update `deliver_now` and `deliver_later` to not raise on errors. They now return an `{:ok, email}` (or `{:ok, email, response}` with `response: true`) or `{:error, error}`. We introduce `deliver_now!` and `deliver_later!` to replace what used to be `deliver_now` and `deliver_later` -- in other words, they raise because that used to be the implementation. Hopefully, that makes for an easy upgrade path. Those who wish to keep the current behavior can switch to `deliver_now!` and `deliver_later!` and keep moving forward. Those who want to handle errors can receive ok/error tuples. Note on `deliver_later` and `!` -------------------------------- `deliver_later` now returns an `{:ok, email_to_send}` or `{:error, error}` if there is an error in the email validations _before_ we schedule the email sending. But if an error occurs during the delayed task, we raise an error. `deliver_later!` will raise an error if we have email validation failures before we schedule the email. This is the existing behavior of `deliver_later`, so it's an easy upgrade for those uninterested in the new change: `deliver_later` -> `deliver_later!`. Note on empty recipients (not nil) ------------------------------- While working on this update, I noticed we did not raise an error when `to, cc, bcc` are all empty lists (after formatting). We decide to keep in line with this behavior, so we do not return an error in those cases either. We do not want to raise on scenarios the recipient list is empty because that means the user of bamboo interacted with those lists. If all of those fields are `nil`, we do return or raise an error because it means the user of bamboo might not have set anything accidentally (`nil` is the default value for all of those). That has always been the case, and will continue to be.
- Loading branch information
Showing
8 changed files
with
301 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.