in Home>>Administration>>Configuration>>System the Site e-mail address refuses to accept xxx@localhost as a valid address.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gpk’s picture

Project: Contact » Drupal core
Version: 7.x-2.x-dev » 7.x-dev
Component: User interface » base system

This looks like a core issue.

See http://api.drupal.org/api/drupal/includes%21common.inc/function/valid_em.... Looks like the problem goes away in PHP 5.3+.

donutdan4114’s picture

Seems to me that instead of using the FILTER_VALIDATE_EMAIL constant, we should grab whatever PHP 5.3+ is using, and have a DRUPAL_VALIDATE_EMAIL constant.

This really should be consistent for all users.

donutdan4114’s picture

Status: Active » Needs work
FileSize
1.81 KB

This patch doesn't really solve the issue stated, however it does open up a discussion about the proper way to validate emails.
I really don't think Drupal should use a PHP constant, as those can change throughout different versions. The best solution is something more universal.

This patch utilizes the regexp from the PHP 5.3+ source code.

There is much debate about the best regexp to be used for emails, so if anyone has further input on this, that would be good.

donutdan4114’s picture

Status: Needs work » Needs review
Dane Powell’s picture

Status: Needs review » Needs work

I am running PHP 5.3 and localhost email addresses still do not validate.

Of course, applying the patch in #3 doesn't help either, since it's based on the PHP 5.3 function.

donutdan4114’s picture

Its based on the 5.3 regex, not any PHP version specific function though.
To make 'localhost' emails validate, we would have to modify the regex string in the patch.

I'm not that good with regex though, and wouldn't even know where to begin modifying that huge regex string :O

But still, I believe Drupal should have a PHP version agnostic way of validating email addresses.
We just need to find the ultimate email regex.

Shadow-Hawk’s picture

Well, since the patch doesn't work to fix it, have we come up with a way to allow the @local to validate?

Seems like the issue just died here without a fix. I run multiple sites on this server, and they all have the base account code in the site email- NOT GOOD! Although, it is kinda funny when I open my yahoo account and find the inbox loaded.

donutdan4114’s picture

If you can find me a piece of regex that will validate an email I'd be happy to make the patch on here. The problem is, there is no such thing as the 'perfect email regex'.

This site has a bunch of them with the different pass/fail examples:
http://fightingforalostcause.net/misc/2006/compare-email-regex.php

crag2012’s picture

xampp 1.8.2 installed and xxx@localhost not recognized as an email address. this seems to be an un-addressed issue since 2012. any help on the horizon No problem at present

Dane Powell’s picture

How have more people not hit this issue? Aren't all of the Core developers running local dev environments? And if so, what email address are they using? Just a little puzzled by this.

alberto56’s picture

Issue summary: View changes
Issue tags: +Needs backport to D7
FileSize
32.13 KB

I came across this issue in #2276491: Email address of user 1 is placeholder-for-uid-1 during tests, which is not a well-formed mail address.

Here, also, is a screenshot.

I'm confirming that the issue subsists in D8, so I'm bumping up the version.

alberto56’s picture

Version: 7.x-dev » 8.x-dev
joachim’s picture

> How have more people not hit this issue? Aren't all of the Core developers running local dev environments? And if so, what email address are they using? Just a little puzzled by this.

I once got local email to work, but it then required me to read mails on the command line which is just too painful :/ I tried to see if there was a way for OS X Mail to read the mailboxes, and that turned out to be nigh impossible.

So I stopped bothering, and I assume that MAMP now eats them :)

Instead, I use https://drupal.org/project/maillog, which logs mails in Drupal and can also output them with dpm(). Much nicer!

And as for email addresses for users on local sites, I just make them up since they are immaterial :)

cilefen’s picture

Status: Needs work » Closed (cannot reproduce)