I am trying to save a user with an email address of "admin@localhost" and get a message saying the e-mail address does not seem to be valid.
I’ve got Evo 1.0.5 running on Vista/XAMPP using Mercury as a mail server. Thunderbird has a user set up that points to localhost and has a user with an email address of admin@localhost. This user (in TB) can send and receive messages to itself. And a PHP script correctly executes a mail() command, which the TB user also receives.
So I *think* things are set up correctly (ie Mercury being able to receive and send messages, as well as recognizing the "admin" user), except that if I add a manager user, for example, in the MODX backend, I cannot save their settings if the email address is admin@localhost.
I can’t escape the feeling that I’m overlooking something. Can anyone explain what email testing is being done that is failing? Has anyone else run into this and got it working?
TIA,
Matt
-
☆ A M B ☆
- 24,524 Posts
Line 68 of save_user.processor.php
// verify email
if ($email == '' || !preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i", $email)) {
webAlert("E-mail address doesn't seem to be valid!");
exit;
}
Notice that the regex checks for a final . followed by from 2-6 alphabetic characters.
@sottwell : Thanks for tracking that down. It would appear that replacing that line with this
if ($email == ’’ ||!(preg_match("/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i", $email) ||
preg_match("/^[A-Z0-9._%+-]+@localhost$/i", $email))) {
would extend the validation to include localhost. Dunno if there’s a good reason not to do that off the top of my head, but for what it’s worth ....
EDIT : scratched out to reflect input from sottwell, et al below.
Thanks again,
Matt
I did some research on regex validation for email addresses when working on SPForm. It turns out that a regex expression that validates any legal email address is about three pages long, so all the regex expressions in use on real-world sites involve compromises of various kinds. I don’t think that address would pass SPForm’s regex either, and TBH, I’m not sure it is a valid email address.
-
☆ A M B ☆
- 24,524 Posts
Apparently it’s not really;
http://tools.ietf.org/html/rfc3696#page-5
The first paragraph in "Restrictions on email addresses" refers to the previous section for the domain part, and that makes it fairly clear that at least one . is required, although there is room for argument about what has to follow that dot.