You must add delimiters to your regular expression:
if (preg_match('/' . $mail_pat . '/', $email, $components)) {
$ mail_pat starts with ^, but ends with another character, which causes an error because there are no matching delimiters.
alexn source
share