Please contact me with any Title: http://www.webjx.comweb @ webjx.com reprinted please indicate the source when you registered on a forum, usually have an e-mail address verification function, when you enter an illegal pattern will present some kind of error prompt letter what title please contact me: http://www.webjx.com web@webjx.com
Reprinted please indicate the source
When you register on a forum, there is usually an e-mail address verification function. when you enter an illegal pattern, an error message is displayed.
We can apply the following rule expression
Ereg ('^ [a-zA-Z0-9 _] @ [a-zA-Z0-9 \-] \. [a-zA-Z0-9 \-\.] $]', $ email );
However, the above sub-statement only checks strings and does not support output. We can further use this formula to return information:
If (eregi ('^ [a-zA-Z0-9 _] @ [a-zA-Z0-9 \-] \. [a-zA-Z0-9 \-\.] $]', $ email ))
{
Return FALSE;
}
Next we can further check whether the host name exists:
List ($ Username, $ Domain) = split ('@', $ email );
If (getmxrr ($ Domain, $ MXHost ))
{
Return TRUE;
}
Else
{
If (fsockopen ($ Domain, 25, $ errno, $ errstr, 30 ))
{
Return TRUE;
}
Else
{
Return FALSE;
}
}
Now let's organize the above two functions with PHP to form a function:
Function checkEmail ($ email)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.