Migrating Web Server from Nix to Windows

madmatt

Awesome is as awesome does.
Political Access
Joined
5 Apr 2002
Messages
13,314
We are in the process of migrating our web server from California to New York. During this transition we decided to go with Windows over Nix.

During testing I am receiving several errors with my mail scripts.

Here we go, showing one of each error:

PHP Notice: Use of undefined constant HTTP_CLIENT_IP - assumed 'HTTP_CLIENT_IP' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 7

PHP Notice: Use of undefined constant REMOTE_ADDR - assumed 'REMOTE_ADDR' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 11

PHP Notice: Use of undefined constant HTTP_USER_AGENT - assumed 'HTTP_USER_AGENT' in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 15

PHP Notice: Undefined index: contactContactName in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 17

Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in D:\walterelwoodmuseum.org\wwwroot\bin\contact.php on line 79

Not sure about the first three errors. I tried adding single quotes, but that didn't seem to work well.

if (getenv(HTTP_CLIENT_IP)) {
$ip = getenv(HTTP_CLIENT_IP);
}
else {
$ip = getenv(REMOTE_ADDR);
}

$hostname = gethostbyaddr($ip);
$client = getenv(HTTP_USER_AGENT);

For the fourth set of errors: We are using $_GET['variable'] but does not seem to be passing through.

$name = $_POST['contactContactName'];

For the last: I have no clue, is it related to the fourth set of errors?

$mailto = "matt@email.com";
$mailcc = "director@email.com";
$subject = "[walterelwoodmuseum.org] Incoming E-mail from ".$name;
$from = "From: $name <$email>\nCc: $mailcc\nReply-To: $email\nMIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\n";

Thank you.
 
do you need any windows specific hosting abilities?

If not, don't use windows for hosting. LAMP is much more stable and easier to fix when broken.
 
Too late for that. Everything has been purchased already.
 
Too late for that. Everything has been purchased already.

Oh and btw, you should come here and ask questions more often, atleast 2 of your moderators work in the hosting industry and can help you with details of said industry.
 
Mark, I understand that and appreciate any and all input. The decision to move to Windows was made. The servers, software, and licensing were purchased by us through our vendor. The servers are being co-located at a datacenter that is nearby.

These PHP scripts all worked prior to the move therefore I think I am missing something that is necessary.

Again, I appreciate your input and I will ask more questions moving forward.
 
Oh god, I can't begin to list the number of issues we've had with running PHP on IIS. I'd rather have teeth pulled.
 
1. IIS does not pass along that information as environment variables. That means you have to find a different way to get the same information. Stuff like

Code:
if (getenv(HTTP_CLIENT_IP)) {
$ip = getenv(HTTP_CLIENT_IP);
}
else {
$ip = getenv(REMOTE_ADDR);
}

$hostname = gethostbyaddr($ip);
$client = getenv(HTTP_USER_AGENT);

will NOT work on IIS. You need to look into using the $_SERVER superglobal as said on the page that LordofLA also linked to:

http://uk2.php.net/manual/en/reserved.variables.server.php

getenv() works on Windows, to get Windows environment variables, but the ASAPI API used to hook into IIS does not set environment variables on the fly. Check a file with just phpinfo(); in it to see what it does send to PHP scripts for you to use.

2. Next up, your error about the $_POST variable not existing, add a debug line of code that reads as such:

Code:
print_r($_POST);

Somewhere near the top, re-run the page and take a look at the source code your browser gets. It will contain a dump of the $_POST variable.

3. As for your mail command, your $from line contains \n. According to the RFC's you need to use \r\n, sendmail and friends (only one that refuses is qmail) will happily accept the malformed email and send it, your new server may not be so lenient. Please add \r\n instead of \n. Also, please show us your mail() command you are using to send out the email.

PHP on IIS:
Now, as for PHP on IIS, I suggest you open up a new Visual Studio window, and start writing some ASP .NET code in C# to replace all PHP code. I agree with Geffy on this one, PHP on IIS is the worst experience EVER. Before a choice like moving from Nix to Windows was made such things should have been considered. I have written my fair share of PHP projects, and I have had clients try to run it on Windows, it is an unsupported configuration. PHP on Windows even with Apache and mod_php is a nightmare.
 
All issues were fixed as of 11:30 PM/ET last night. The migration (web was uploaded the day before, email was first yesterday, DNS, name servers) started at 5:00 PM.

I plan on converting all code over to ASP, but it's going to take time.

The problem with mail() was it didn't like From: $name <$email>, I had to change it to From: <$email> and it worked fine.

Thank you, I will make some of these changes for the shortterm.
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back