Hey, @GhostMech thanks for your reply, I found a solution online.
Mail::send()
Method does not return anything so in my case when I'm using it inside the if () statement it never returns anything true so by default it returns false. That's why I am getting the else () statement returned.
So in order to get something like this to work, you would have to use an if() statement like this
$post = (object) $_POST;
Mail::to($post->email)->send(new OrderReceived($post));
if (count(Mail::failures() < 0)) {
echo "Thank you mail sent";
} else {
echo "There was an error";
}
Mail::failures
Returns an array of failed recipients
Just in case anyone else runs into this problem.
Cool. Thanks for sharing. I always inspect what my IF statements return. Some PHP functions don't always return boolean, so you have to evaluate with something like if ($var === true), or something like that.
Glad you got it solved.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community