ClearFoundation Tracker - ClearOS
View Issue Details
0000066ClearOSapp-settings - System Settingspublic2010-03-27 13:012010-06-01 21:02
bchambers 
user2 
normalminoralways
closedfixed 
5.1 
5.25.2 
0000066: Allow 'localhost' as a valid hostname for SMTP hostname field
Mail notification uses the Network class's "IsValidHostname" function to validate input of the form variables. This function checks for the presence of a 'period', and throws a validation error if the hostname does not contain at least one:

/var/webconfig/api/Hostname.class.php

if (substr_count($hostname, ".") == 0) {
  $errmsg = NETWORK_LANG_ERRMSG_HOSTNAME_MUST_HAVE_A_PERIOD;
  $this->AddValidationError($errmsg, __METHOD__, __LINE__);
  return false;
}

The entry 'localhost' is valid...but in the Network class, this may want to be more strict.

For the Mail Notification, a check for 'localhost' before the network class validation routine could be a solution:

if ($host == 'localhost')
  return true;
$network = new Network();

if (! $network->IsValidHostname($host))
  throw new ValidationException(implode($network->GetValidationErrors(true)));
return true;

There are lots of 'workarounds' to get around this bug until it is fixed.

Use the local IP (192.168.1.1, for example)
Use the local hostname (clear.lan, for example)
Use the external hostname (myclearbox.poweredbyclear.com, for example)
Create an entry in the hosts file.
No tags attached.
Issue History
2010-03-27 13:01bchambersNew Issue
2010-03-27 13:40timb80Note Added: 0000063
2010-03-28 20:05user2Statusnew => assigned
2010-03-28 20:05user2Assigned To => user2
2010-03-28 20:07user2Target Version => 5.2
2010-03-30 18:03user2Checkin
2010-03-30 18:03user2Note Added: 0000072
2010-03-30 18:03user2Statusassigned => resolved
2010-03-30 18:03user2Resolutionopen => fixed
2010-05-19 11:30user2Fixed in Version => 5.2
2010-06-01 21:02user2Statusresolved => closed
2010-08-18 15:05user2Note Deleted: 0000072

Notes
(0000063)
timb80   
2010-03-27 13:40   
Another alternative?

/var/webconfig/api/Network.class.php line 300

Function "IsValidHostname($hostname)"

Change
Code:
                if (substr_count($hostname, ".") == 0 ) {

TO

                if (substr_count($hostname, ".") == 0 && $hostname!='localhost') {