ID:               38091
 Comment by:       rick at longbowgames dot com
 Reported By:      danb1974 at gmail dot com
 Status:           Assigned
 Bug Type:         Mail related
 Operating System: windows xp pro
 PHP Version:      5.1.4
 Assigned To:      pajoye
 New Comment:

This isn't really a bug in Windows, since the official documentation
for Winsock[1] clearly states that the name returned by gethostname "can
be a simple host name, or it can be a fully qualified domain name." 
Like many parts of Winsock, this is slightly different from the typical
behaviour of the POSIX function of the same name, which usually returns
a FQDN.

Actually, while the name returned by gethostname() is *usually* a FQDN
on a POSIX machine, I don't actually think it's guaranteed there,
either.

For a C solution, the code given by danb1974 should work.  An easy way
to do it in pure PHP is, instead of just calling gethostname(), call
gethostbyaddr(gethostbyname(gethostname())).

Thanks,

-Rick-

[1] http://msdn.microsoft.com/en-us/library/ms738527(VS.85).aspx


Previous Comments:
------------------------------------------------------------------------

[2009-06-20 08:53:14] paj...@php.net

Reopen, seems to be still valid.

------------------------------------------------------------------------

[2006-07-14 07:45:01] danb1974 at gmail dot com

It seems it's not enough to just gethostname. You have to do something
like this (this is not actual production code):

hostent *hent;
gethostname(hname, sizeof(hname));
hent = gethostbyname(hname);
strcpy(hostname, hent->h_name); // h_name is the official name
according to winsock api

------------------------------------------------------------------------

[2006-07-14 06:45:35] rona...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The windows XP "feature" for domain name resolution 
apparently gives out a bogus answer. This is an XP bug, 
not a PHP bug. Additionally, "trashcan2.intranet" is not 
a FQDN. See: <http://en.wikipedia.org/wiki/FQDN>.

------------------------------------------------------------------------

[2006-07-14 06:23:35] danb1974 at gmail dot com

Ok now I'm confuzed.

* smtp requires helo to send fqdn and not just the hostname (it's
stated somewhere in the rfc's)
* windows xp fqdn is what the computer reports as "full computer name"
(at least so does some say, see
http://www.ima.com/support/regprob.html)
* a windows xp joined to a domain (a) does not give you any choice
about the hostname, it's the computer name which is obviously not fqdn
and (b) does report the correct name as "full computer name"
* on linux it works correctly (not using hostname but hostname -f value
which is the fqdn)

So at this point it's basically "I cannot send mail from xp to an
unforgiving mail server and yes it's a feature so I have to live with
it"

------------------------------------------------------------------------

[2006-07-13 14:32:50] il...@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The host name use is the same one as your machine will report 
if you run ipconfig /all (Host Name value).

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/38091

-- 
Edit this bug report at http://bugs.php.net/?id=38091&edit=1

Reply via email to