Starting a new series about code Snippets, In this series we share some useful code snippets of HTML, HTML5, CSS, CSS3, PHP, Javascript and jQuery snippets. We hope that these snippets will worthwhile for our readers and should help in your projects.

Today we share a PHP Code Snippets “Check valid email address”.

This is a valid email.

echo ‘

This is an invalid email.






Passion is beyond limitation. If you’re passionate about ANYTHING, nobody can stop you not to do what you want. Blogging and Web Designing is my passion that don’t drive me to do what I want but push me as well to share fanatical stuff with people.


    • Avatar

      All you are doing there is checking if the domain used in the email address exists and accepts email. It doesn’t prove that the email address in question actually exists. May as well just use filter_var or regex and save on the resources.

  1. Avatar

    Note that you need to have a subdomain of a top domain or whatever its called.

    This does not work: foo@bar
    This works: foo@bar.baz

    • Avatar

      Yes filter_var does not allow some addresses that are perfectly valid according to the RFC specs. foo@bar is actually a valid email address.

    • Avatar

      I had the problem this week : with the mail “tester@customer-ä.de” … so I will use a regex next time.

  2. Avatar

    Might as well of just posted a link to the PHP page about using filter_var. You don’t even list the available options nor do you mention any of the issues that come with using filter_var.

Write A Comment