Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Check MX for email addresses

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 07-06-2005, 08:15 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

eXpert
  
Join Date: Jun 2004
Location: Duluth, MN
Posts: 242
 

Default 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.

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
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #2  
Old 07-06-2005, 01:04 PM
 
bluecat bluecat is offline
 

X-Adept
  
Join Date: Nov 2002
Posts: 674
 

Default

Thank you, will try this very soon.
__________________
--------------------
X-Cart Gold 4.1.11
Linux/Apache
--------------------
Reply With Quote
  #3  
Old 07-06-2005, 01:45 PM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default

this one all tested and working ok?
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #4  
Old 07-07-2005, 06:27 AM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

eXpert
  
Join Date: Jun 2004
Location: Duluth, MN
Posts: 242
 

Default

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.
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #5  
Old 07-07-2005, 06:34 AM
 
donavichi donavichi is offline
 

X-Adept
  
Join Date: Apr 2004
Location: United Kingdom
Posts: 697
 

Default

excellent news!

That's a cracking mod there then... Thank you.
__________________
Best regards,

Donavichi.
- - -

Website Copywriting || Web Design || FAQs || Home & Garden Blog
Reply With Quote
  #6  
Old 07-09-2005, 02:27 AM
 
cotc2001 cotc2001 is offline
 

X-Man
  
Join Date: Feb 2003
Location: Shrewsbury, UK
Posts: 2,351
 

Default

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?
__________________
x-cart 4.0.5 (live and heavily modded)
Server: freebsd
Reply With Quote
  #7  
Old 07-11-2005, 01:00 PM
 
sstillwell@aerostich.com sstillwell@aerostich.com is offline
 

eXpert
  
Join Date: Jun 2004
Location: Duluth, MN
Posts: 242
 

Default

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
__________________
No longer using Xcart, was good while it lasted.
Reply With Quote
  #8  
Old 02-25-2006, 02:25 PM
 
m.higgins m.higgins is offline
 

Newbie
  
Join Date: Feb 2006
Posts: 7
 

Default Tip Top!

Works for me on Gold 4.0.17 - Top MOD!!
__________________
version 4.0.19
php 5
Reply With Quote
  #9  
Old 02-25-2006, 07:23 PM
 
zardos zardos is offline
 

Senior Member
  
Join Date: Jun 2004
Location: UK England
Posts: 140
 

Default

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
__________________
X-Cart V4.0.18
PHP 4.3.10
MySQL Server 4.0.22
Apache/1.3.33 (unix)
OS - Linux
Reply With Quote
  #10  
Old 02-26-2006, 02:03 AM
 
m.higgins m.higgins is offline
 

Newbie
  
Join Date: Feb 2006
Posts: 7
 

Default You're right!!

I didn't check that - you're right it doesn't seem to work on the newsletter subscription...
__________________
version 4.0.19
php 5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:46 AM.

   

 
X-Cart forums © 2001-2020