Support the ongoing development of →
posted 5 years ago
Last updated 5 months ago.

What is Mail returning in that IF statement?


Hey, @GhostMech thanks for your reply, I found a solution online.


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";

Returns an array of failed recipients

Just in case anyone else runs into this problem.

Last updated 5 years ago.

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!


Your banner here too?


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 - All rights reserved.