We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18913
    • 654 Posts
    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
      • 18913
      • 654 Posts
      Solved, I think.

      What I did was go to the Mercury configuration panel and under "Aliases" added "[email protected]" and pointed this to the "real" address of "admin@localhost". Then I used this localhost.com address in the MODX backend when setting up and saving the user. This approach also allows for a number of users to be set up with different "fake" emails, which all point to one valid one on the localhost.

      Maybe there’s a better way to deal with this (which I’d still like to know about), but for the time being this seems to do the trick.
      Matt
        • 26931
        • 2,314 Posts
        Ha! thanks for finding out smiley was wondering myself
          • 28042 ☆ 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.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 18913
            • 654 Posts
            @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

              • 3749
              • 24,544 Posts
              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.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 28042 ☆ 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.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org