Re: [INTERNALS-WIN] mail() sending local hostname instead of fully-qualified hostname as HELO
| From: | Rick Yorgason | Date: | Thu, 25 Jun 2009 19:15:27 +0000 |
| Subject: | Re: [INTERNALS-WIN] mail() sending local hostname instead of fully-qualified hostname as HELO | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals.win |
| Request: | Send a blank email to internals-win+get-520@lists.php.net to get a copy of this message | ||
Kalle Sommer Nielsen wrote:
As far as I reach the documentation, then it can be either wayI'm not sure where you saw that. In the gethostname documentation I found[1], it seems to be pretty specific in the remarks section that the name returned will either be a simple host name or a FQDN, and that gethostbyname will parse it properly. The example on the gethostbyname[2] docs *does* use the same method you're using (except they use isalpha rather than isdigit), but that's because they're taking the host name form argv rather than from gethostname.
and I don't think that gethostbyname would like an IP as an argument when theres also the gethostbyaddr.After a quick test, it seems that if you pass an IP address to gethostbyname, it just gives you that IP address back. I did play around with passing an IP address to your fallback code, and found the following issues: * You're calling gethostbyaddr incorrectly; if the code ever *did* get there, it would stall for a few seconds and then fail. gethostbyaddr expects the first parameter to be an in_addr structure (casted to a char* for some stupid reason), as returned by inet_addr. See the example in [3]. * If you change the code to use inet_addr, beware that it's not IPv6 aware; you'll need to use inet_pton[4] for IPv6 code, and unfortunately that function is only supported by Vista and Win2k8. * isdigit is not good enough to detect IP addresses, since an IPv6 address can start with a colon.
I don't if its really needed, but as a "just" in case to prevent future "bugs" it might be a good thing to also have this posibility.Fair enough. If the code is fixed, then it certainly wouldn't hurt. If it were me, though, I just wouldn't bother; especially in light of the IPv6 issue. If you still wanted to be extra-safe, it would probably be better to return the IP address in square-brackets, since that's a valid HELO value[5].
I want to include this bug fix in the first 5.3 maintaince release (5.3.1), as its way to late in the 5.3 process to include this non critical bug fix.I assumed as much. I ended up changing my SMTP settings to avoid this bug, so I'm not in a big rush to see it fixed. Cheers, -Rick- [1] http://msdn.microsoft.com/en-us/library/ms738527(VS.85).aspx [2] http://msdn.microsoft.com/en-us/library/ms738524(VS.85).aspx [3] http://msdn.microsoft.com/en-us/library/ms738563(VS.85).aspx [4] http://msdn.microsoft.com/en-us/library/cc805844(VS.85).aspx [5] http://en.wikipedia.org/wiki/Anti-spam#HELO.2FEHLO_checking