Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a simple PHP file to handle a form and send it from a contact page to the admin of a site. It worked great on my own test server (running Windows Server), but when I transferred it to another Windows Server based machine it stopped working. I've double checked and all resources are there (I copied EVERYTHING). Everything else on the site works fine - it even gives me the success message when I press 'Send'. Anyone know what could be going wrong? The new server is on, could they have turned something off that disables the PHP script?

share|improve this question
up vote 1 down vote accepted

Check with your hosting company's support. They may not permit emailing from within your site. Depending on just how they do that your script may well think that the message was sent, even though it never leaves the system. Also check that the message hasn't been swallowed by your spam filter.

share|improve this answer
Great call on the spam filter. WOW. That was it. lol I wish I was kidding – Zakman411 May 9 '11 at 8:22
@Zakman411, in that case you may want to check your SPF record in DNS to ensure the web server is authorised to send mail for your domain. – John Gardeniers May 9 '11 at 11:34

The mechanism used for sending mail is configured in you server's php.ini file. Check to see what mechanism the server is using, and whether that mechanism works. For example, if you're using SMTP to "localhost", make sure that you're also running a local SMTP server that allows you to relay your outbound mail.

Find out from the hosting provider what the preferred way to send mail from PHP is. They should have instructions appropriate for their hosting environment. It may involve a call or two to ini_set.

To test, just create a simple page like this, and test to make sure you get the mail.

   if (mail("your@email.addr","Test","hello")) { 
      echo "OK";
   } else {
      echo "Fail";
share|improve this answer
Unfortunately I can't do much since it's a shared hosting account I'm uploading to. When I ran the code on my own dedicated server, I didn't have to specify "localhost" or anything in my PHP. It just ran. Is something wrong with the server you think? – Zakman411 May 9 '11 at 8:06
@Zakman411: See additional comments – tylerl May 9 '11 at 8:13
Thanks for the response. I tried the test on shared hosting. Said "OK" but I never got the message :( Ughh. – Zakman411 May 9 '11 at 8:19
turns out it was my good ol' spam filter. But thanks for the insight man – Zakman411 May 9 '11 at 8:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.