File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 78
78
$ g_phpMailer = null ;
79
79
80
80
/**
81
- *
82
81
* Use a simple perl regex for valid email addresses. This is not a complete regex,
83
82
* as it does not cover quoted addresses or domain literals, but it is simple and
84
83
* covers the vast majority of all email addresses without being overly complex.
85
84
* @return string
86
85
*/
87
86
function email_regex_simple () {
88
- return "/([a-z0-9!#*+\/=?^_{|}~-]+(?:\.[a-z0-9!#*+\/=?^_{|}~-]+)*) " . # recipient
89
- "\@((?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)/i " ; # @domain
87
+ static $ s_email_regex = null ;
88
+
89
+ if ( is_null ( $ s_email_regex ) ) {
90
+ $ t_recipient = "([a-z0-9!#*+\/=?^_{|}~-]+(?:\.[a-z0-9!#*+\/=?^_{|}~-]+)*) " ;
91
+
92
+ # a domain is one or more subdomains
93
+ $ t_subdomain = "(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?) " ;
94
+ $ t_domain = "( $ {t_subdomain}(?:\. $ {t_subdomain})*) " ;
95
+
96
+ $ s_email_regex = "/ $ {t_recipient}\@ $ {t_domain}/ " ;
97
+ }
98
+ return $ s_email_regex ;
90
99
}
91
100
92
101
/**
You can’t perform that action at this time.
0 commit comments