Category: Laravel, PHP

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.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners