Hi brunodemarchi,
You could use the Observer (publisher-subscribers) to maintain notified all subscriber classes or entities that you need to know about the e-mail activity through some events.
The mail class has a failures method which should give you any addresses that it failed to send to. Not tested this, but this should work...
Mail::send(...)
if( count(Mail::failures()) > 0 ) {
echo "There was one or more failures. They were: <br />";
foreach(Mail::failures as $email_address) {
echo " - $email_address <br />";
}
} else {
echo "No errors, all sent successfully!";
}
I believe Mail::send() returns a count of sent items, therefore if you're sending to a single recipient, your code could be as simple as your own example:
if (Mail::send(...)) {...
If you are sending to more than 1 recipient then the previous post is probably more suitable.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community