packy
2 months ago
283
4
Laravel

Ignore error from Mail method

Posted 2 months ago by packy

Is there a way to ignore any errors from a Mail method? Here is the scenario, I have an online ordering system that doesn't require you to be a user. When someone places and order, the controller stores the order in the DB and then sends an email to the customer "hey we got your order, here is the receipt". This works great until a user misspells his email. So 1 out of every 1000 orders someone will accidentally use something like "@gmail.con" instead of "@gmail.com". When Mailgun goes send it the systems throws a 500 error because its not a real email. This then pops up on the users screen so they think the order wasn't placed even though it was. How to you handle this? Can you ignore an error from Mail::to($this->email)->send(new NewOrderCustomer($order, $location)); so if they use a wrong email its just on them? We just dont want users to place 10 orders because they think its an order error. Or how can you verify its a real email?

Please sign in or create an account to participate in this conversation.