Use this instead of a regular expression:
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
//Valid email!
}
Using regular expressions to validate email addresses is not recommended as it is certainly not pretty, especially if you don't want to exclude somebody who has a valid email address that is correct according to RFC 822 grammar.
http://www.php.net/filter_var is your best bet.
A crazy example of a regex that attempts to validate email addresses according to RFC 822 grammar:
(?:(?:
)?[ ])*(?:(?:(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ]
)+||(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(
?:
)?[ ])+||(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[
]))*"(?:(?:
)?[ ])*))*@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-
31]+(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*
](?:(?:
)?[ ])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+
(?:(?:(?:
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:
(?:
)?[ ])*))*|(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[ ])+|
|(?=[["()<>@,;:".[]]))|"(?:[^"
\]|\.|(?:(?:
)?[ ]))*"(?:(?:
)
?[ ])*)*<(?:(?:
)?[ ])*(?:@(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
r
)?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[
])*)(?:.(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)
?[ ])+||(?=[["()<>@,;:".[]]))|[([^[]
\]|\.)*](?:(?:
)?[ ]
)*))*(?:,@(?:(?:
)?[ ])*(?:[^()<>@,;:".[] 00-31]+(?:(?:(?:
)?[
])+||(?=[["()<>@,;:".[]]))|[([^[]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