Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 Domain.com, could they have turned something off that disables the PHP script?

share|improve this question

2 Answers 2

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.

EDIT
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.

<?php    
   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

 
discard

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.