As many of you may be aware there’s a lack of getmxrr() support in Windows, which dates back as far as 1999.
It’s not a major problem for me as an individual because I never use WIN32 PHP in production, but for development and for the purpose of wide distribution it can raise an issue.
Apparently the lack of support in win32 is due to the lack of “res_search” in “bindlib_w32″, I’m surprised this hasn’t been fixed already.
The official PHP.net documentation for the getmxrr() function states:
Note: This function is not implemented on Windows platforms. Try the » PEAR class » Net_DNS.
However, there are problems with this suggestion…
- Some users don’t have access to install the required PEAR module.
- pear/Net_DNS requires PHP extension “mhash” – some users may not have this installed.
- The Net_DNS class does not have a direct equivalent to getmxrr() so results may not be as expected.
- It’s not a portable solution, especially if some users experience the above issues.
This isn’t going to be a realistic option for many users.
So, what are the alternatives? Do they have any issues?
- Use exec() in conjunction with “nslookup.exe“.
- When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.
- “nslookup.exe” may not exist on the system.
- PHP may not have permission to run “nslookup.exe”.
- Write your own class/function to fsockopen() via UDP to a name server and parse the returned information.
- Long and overly complex.
- Requires understanding of the DNS related RFCs.
- Reinventing the wheel, as Net_DNS already handles this.
- Results may not be as expected.
- Fix the implementation problem in PHP core.
- Not very simple to implement.
- May be a complex issue.
- Not backwards compatible.
I think the obvious option here is to run with the first option of using “nslookup” and hope for the best.
With any luck you will find the “getmxrr() support for Windows” function in on the getmxrr() manual page (find the latest here).
As I write this, and go over the article again, check my links, I see an update on the PHP Bug #5311 tracker:
As a new year present, all DNS functions are now available on windows, 5.3 and 6 (head).
This is good news, all that remains is for PHP_Compat to catch up and use the above suggestions
Update: I am now helping the PHP_Compat team. View the getmxrr() support for windows feature request.
Update2: I have now decided to support checkdnsrr() as well. Download checkdnsrr() support for windows.
Update3: I have now decided to support dns_get_record() as well. Coming soon.
- Cex.co.uk site errors After browsing the cex.co.uk website for some time I came...
- Windows Genuine Advantage Removal First of all for those that don’t know, Windows Genuine...
- PHP coding standards and best practices I have been using PHP for a long time now,...
- Adding fonts into photoshop without adding them to windows If you use Photoshop for any kind of graphic or...