what’s up?I am working on a SAAS application for my current company and facing the issue of sending emails, actually bad emails, those comply with the RFC.So that means basic email validation is not working from the Laravel side and we are processing emails to ‘example@gmail’ like email addresses (yes RFC allow this email address, though it does not exist). Though the emails are not sending, our queue works for these emails and it consumes unnecessary resources and sends the request to the Mailgun also.So, I did some R&D and find out this very simple solution.
If yes, then don’t forget to thanks me in the comment ;)You just need to check the email with filter_var($email, FILTER_VALIDATE_EMAIL) function.
Check more on php.net If the email is invalid then we throw an exception with a custom message. If the email is valid then we send the email through Laravel’s way.