My PHP form doesn’t work, send any mail

If you do the same as it is written in PHP forms manual, upload the sample  PHP form code, submit the form and the message  "Your form has been submitted"  will be displaced. But it isn’t important how many times you tried, your PHP form is not able to work. It doesn’t send mail and you don't receive any form results. What to do??

Here are some methods to check if your form doesn’t work:

» Can the time help?

Please wait for some time (hour) before to start panicking as there is possibility of delaying between the e-mail sending and your mail server receiving it.

» Is it marked as SPAM?

It is possible that the form e-mail can be identified as SPAM by a SPAM filter. Look inside your SPAM folders to see if the form mail stopped there. In the case if your SPAM filter supports it try to add the From: address to a white list (always accept mail from).

» Mail sending to remote addresses is blocked?

There are hosts which prevent the user "guest" from sending out mail to remote addresses (PHP and CGI scripts generally run as nobody). During your form testing, make sure the recipient e-mail address is a local address (@yourwebsite.com) rather than such email provider as (hotmail, aol, yahoo, gmail, your ISP, ...etc.).

For example, if your form is hosted on yourwebsite.com you must be insure the recipient address is like this @mywebsite.com (a local domain e-mail address may be like info@mywebsite.com, webmaster@mywebsite.com, your.name@mywebsite.com).

» Is PHP mail function working?

It is possible that PHP mail function is disabled or not configured in such way on your server. The easiest way to check if the  e-mail sending works is to use this code. It is as simple as it gets, if this code doesn't work nothing more will happen:

<?php
mail('you@yourmail.com','Test mail','The mail function is working!');
echo 'Mail sent!';
?>
  • save this code as mailtest.php file
  • change you@yourmail.com to your e-mail address
  • upload mailtest.php to your server
  • open mailtest.php in your web-browser (http://yourwebsite.com/mailtest.php)
  • check for your inbox to see if a test message arrived.

Did the test mail arrive?

» YES!

  • check your form script for errors look like e-mail address misspells
  • use the same e-mail address with your form recipient
  • check your SPAM filters and SPAM mailboxes

» NO...

  • Your host or disabled sending mail with PHP or it is not configured in right way. In any case you may contact to your host and ask to check PHP mail settings. You can give them a link to your mailtest.php script which will show that you’ve tested it with a help of script as simple as it gets and it is just not working.
  • If you are running PHP on your own machine you may to configure PHP properly. How? Check PHP manual or ask Google

We hope that it will help you!