// Vlidate email and domain name
1
2 <?php
3
4 function validate_email($email){
5
6 $exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
7
8 if(eregi($exp,$email)){
9 if(checkdnsrr(array_pop(explode("@",$email)),"MX")){
10 print("$email is ok.<br>");
11 }else{
12 print("$email is ok. But domain is not.<br>");
13 }
14 }else{
15 print("$email is not ok.<br>");
16 }
17 }
18
19 validate_email("shantanu.ok");
20 validate_email("shantanu.ok@gmail.com");
21 validate_email("shantanu.ok@fsjaldkfjlsfjsljflsfjsldk.com");
22
23 ?>