This takes the email validation checking one step further. It checks to see if you can actually deliver email to the address the customer specifies by looking for an MX record.
Why? Keeps people from putting in bogus emails that will just bounce back to you.
Warning! Backup your Xcart, this mod is easy but could potentially cause your dog to be abducted by smurfs.
1. Backup
include/func.php to
include/func.php.bak
2. Change this function in
include/func.php from this:
Code:
#
# This function checks if email is valid
#
function func_check_email($email) {
#
# Simplified checking
#
$email_regular_expression = "^([-\d\w][-.\d\w]*)?[-\d\w]@([-!#\$%&*+\\/=?\w\d^_`{|}~]+\.)+[a-zA-Z]{2,6}$";
#
# Full checking according to RFC 822
# Uncomment the line below to use it (change also check_email_script.tpl)
# $email_regular_expression = "^[^.]{1}([-!#\$%&'*+.\\/0-9=?A-Z^_`a-z{|}~])+[^.]{1}@([-!#\$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$";
return preg_match("/".$email_regular_expression."/i", stripslashes($email));
}
To this
Code:
#
# This function checks if email is valid
#
function func_check_email($email) {
#
# Simplified checking
#
$email_regular_expression = "^([-\d\w][-.\d\w]*)?[-\d\w]@([-!#\$%&*+\\/=?\w\d^_`{|}~]+\.)+[a-zA-Z]{2,6}$";
#
# Full checking according to RFC 822
# Uncomment the line below to use it (change also check_email_script.tpl)
# $email_regular_expression = "^[^.]{1}([-!#\$%&'*+.\\/0-9=?A-Z^_`a-z{|}~])+[^.]{1}@([-!#\$%&'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}$";
list ( $Username, $Domain ) = split ("@",$email);
if (getmxrr($Domain, $MXHost)) {
return preg_match("/".$email_regular_expression."/i", stripslashes($email));
}else{
return false;
}
}
Note: This does not work on Windows Servers