There is a particular member in my site that needs access but her corporate email that is attached to her account has an apostrophe in it. How do I allow EE to allow apostrophes in emails for member accounts?
-
If it was me I would be getting her tech department to create her an alias without the apostrophe. Would save a lot of hassle.– John Henry DonovanMar 9, 2013 at 1:56
-
That was my first thought, but this person works for a giant multi-national oil company who's less likely to change their email stuff any time soon.– lealeaMar 9, 2013 at 2:17
2 Answers
In order to allow the apostrophe, I had to hack the core code. Specifically, a CodeIgniter helper within:
/system/codeigniter/system/helpers/email_helper.php
In there, find around line 40 this:
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
Then replace that line with this instead:
return ( ! preg_match("/^([a-z0-9\+_\-']+)(\.[a-z0-9\+_\-']+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
Found the particular regex in an old EE Forum Thread here: http://ellislab.com/forums/viewthread/84711/
Anything wrong with this approach or the expression used?
-
Yup, I would just do this and document it in a 'hacks.txt' in the site root for reference. :) Nov 12, 2013 at 10:43
Incase someone else comes to this post.. this has heen resolved in the developer version of codeigniter.
https://github.com/EllisLab/CodeIgniter/issues/3116
Be sure to also update the Form_validation class as the email validation function there is different from the email_helper functions.