Skip to content
New issue

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

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

Already on GitHub? # to your account

Event email output sended twice when error occours #37735

Closed
PedroPMS opened this issue Jun 18, 2021 · 2 comments
Closed

Event email output sended twice when error occours #37735

PedroPMS opened this issue Jun 18, 2021 · 2 comments

Comments

@PedroPMS
Copy link

PedroPMS commented Jun 18, 2021

  • Laravel Version: 8.34.0
  • PHP Version: 7.4.18

Description:

In my project I have the option to send an email if the event ends successfully and the option to send if a failure occurs, using. The user can choose both or neither.

I do an if to check the user's choice, like this:

if ($schedule->sendmail_success) {
    $event->emailOutputTo($schedule->email);
}

if ($schedule->sendmail_error) {
    $event->emailOutputOnFailure($schedule->email);
}

If the user wants to receive all outputs and there is a failure, the email is sent twice, the emailOutputTo is called twice. (In this case it is simple to solve, just use the emailOutputTo because this method doesn't care about the result).

But, if the user wants to receive only the successful outputs, and an error occurs in the process, he receives the email anyway, because the emailOutputTo does not make this distinction.

Possible solution

To solve this little problem I believe an emailOutputOnSuccessTo method solves it. So the class would have 3 methods to send email with the output:

emailOutputTo -> send the output regardless of the result

emailOutputOnFailureTo -> send output only on failure

emailOutputOnSuccessTo -> send output only on success

@driesvints
Copy link
Member

Seems like a feature request. Feel free to attempt a PR 👍

@PedroPMS
Copy link
Author

Yeah, I noticed after creating the issue that it looked more like a feature in laravel and a bug in the package I use.

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

No branches or pull requests

2 participants