X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Check MX for email addresses (https://forum.x-cart.com/showthread.php?t=15026)

sstillwell@aerostich.com 07-06-2005 08:15 AM

Check MX for email addresses
 
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. :wink:

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

bluecat 07-06-2005 01:04 PM

Thank you, will try this very soon. :)

donavichi 07-06-2005 01:45 PM

this one all tested and working ok?

sstillwell@aerostich.com 07-07-2005 06:27 AM

Quote:

Originally Posted by donavichi
this one all tested and working ok?


Donavichi,

I just did preliminary tests such as the following.

1. Correct email in newsletter subscribe box (pass)
2. Bad syntax in subscribe box (fail)
3. Bogus domain in subscribe box (fail)

Did the same three tests for registering and it works fine.

I think there may be one caveat. When a user tries to unsubscribe from a news letter, if their email (domain) onced worked and now does not, I don't think it will let them unsubscribe as xcart checks the syntax of the email before it tries to unsubscribe it.

Theoretically, this should not be a problem, because if they have not MX record then they aren't getting your emails anyway.

donavichi 07-07-2005 06:34 AM

excellent news!

That's a cracking mod there then... Thank you.

cotc2001 07-09-2005 02:27 AM

Ive got it working fine on the newsletter subscription but it doesnt seem to affect customer registrations?

i.e i can enter an email address of sghdgfhdsfgew@fgsdfg.com and it will still accept it.

Any ideas or is it just me?

sstillwell@aerostich.com 07-11-2005 01:00 PM

Quote:

Originally Posted by cotc2001
Ive got it working fine on the newsletter subscription but it doesnt seem to affect customer registrations?

i.e i can enter an email address of sghdgfhdsfgew@fgsdfg.com and it will still accept it.

Any ideas or is it just me?



I'm running 4.012, when I try to register with that email address I get the error box at the top that says "Please make sure you properly filled in all the required fields!"

and the "<<" arrows next to the email address with the error message of "Sorry, that email address doesn't appear to be correct. "

Can you enter in an email like "johnson&@aol.c2m"?
See if it does a syntax check.

If that success then your version is not doing email checking during registration, if it fails then you have to hunt down how Xcart is doing email validation during registration.

Sorry :cry:

m.higgins 02-25-2006 02:25 PM

Tip Top!
 
Works for me on Gold 4.0.17 - Top MOD!!

zardos 02-25-2006 07:23 PM

Hi

Not working on the newsletter subscription.
If you add anything with a .com, .co.uk, etc it will go through.

Example: abc@123.com : 123@abc.co.uk all pass

m.higgins 02-26-2006 02:03 AM

You're right!!
 
I didn't check that - you're right it doesn't seem to work on the newsletter subscription...


All times are GMT -8. The time now is 03:15 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.