I am currently SwiftMailer 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.
However, my validator doesn't pick up accidental double dots (..) in email addresses like:
ben..sinclair@email.com OR ben.sinclair@email..com
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?
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;
}