Why PHP should NOT be run on Windows

I ran into an issue today sending emails from a CMS system that was running on a WAMP installation due to the client’s request.  We were using the default PHP mail() function to send emails from the form and the emails were not sending.

The first issue we ran into was the setup of the SMTP server itself.  In the php.ini file we had the SMTP server set to localhost or port 25.  The client confirmed to us that they were able to send email from the server using the Thunderbird email client.  Unsure of what was going on, I did a quick Google search and found this post.  The relative part to our situation is here:

5 – Configure IIS SMTP Relay Restrictions:

Once you’re done with PHP.INI, head over to Internet Information Services Manager. Assume that the IIS is running SMTP server also to send out email. You should be able to see the entry inside IIS manager stated “Default SMTP Virtual Server” or similar items. Now right click and access the properties page from “Default SMTP Virtual Server” as it’s shown below.

on the properties page move to “Access” tab and click on “Connection” and you will be able to see which server/IP’s are allowed to make connection to the server. If “127.0.0.1” IP is not there on the list, add it using the “Add” button, additionally you may also insert your server IP on the list.

Once you are done at the “Connections” window, click on OK button to accept the information. Now Click on “Relay” button at the “Access” tab and setup the relay options for the server. Grant the IP’s allowed to relay out mail for the mail server. Make sure “localhost” and IP “127.0.0.1” are granted for relay, addition to that you can also insert your domain name and IP.

Once you are done with “Relay Restrictions” window, click ok to accept the options and then click “Apply” and “Ok” button respectively to go back to the main screen of IIS Manager.
Now you can restart IIS from IIS manager.

Once those steps were completed I was able to send and email to my self using a simple test script.  I thought everything was good.

Less then 30 minutes later we heard from the client that the forms were still not sending the emails.  So, back to debugging the issue.  After adding some code to the form processing page and viewing the errors being generated by PHP, we saw this: warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address

Back to Google where I came across this drupal forum thread.  About a third of the way down the page there is a post that says:

..On Windows server, the mail() function doesn’t accept email address such as:

"name <email@host.com>"

Change it to a simpler one like this will work:

"email@host.com"
Sure enough…we changed our headers being passed to the mail function and the emails were sent.
September 19th, 2008 Posted in Development, Technology, Uncategorized

Tags: , , ,

Sorry, comments for this entry are closed at this time.