Support the ongoing development of Laravel.io →
posted 6 years ago
Last updated 1 year ago.
0

What is Mail returning in that IF statement?

0

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.

Last updated 6 years ago.
0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.