Validating email address - stopping double dots
<p>I am currently <a href="http://swiftmailer.org/" rel="nofollow">SwiftMailer</a> to send out emails. I have a seperate email validation script that checks emails to ensure they are valid before using SwiftMailer to send. It works pretty well.</p>

<p>However, my validator doesn't pick up accidental double dots (..) in email addresses like:</p>

<p>ben..sinclair@email.com
OR
ben.sinclair@email..com</p>

<p>Here's my code... what would I need to add in to give an error if they put double dots anywhere in the email address?</p>

<pre><code>function valid_email($email) {
    if (preg_match("/[_a-z0-9-]+(\.[_a-z0-9-]+)*@([_0-9a-z][_0-9a-z-]*[_0-9a-z]\.)+[0-9a-z][a-z]+/", $email, $matches))
        return true;
    return false;
}
</code></pre>
