It's difficult to diagnose why your script not be sending emails unless there is an obvious syntax error.
So you need to troubleshooting this problem as the following to find any potential pitfalls you may be encountering:
1- Make sure error reporting is enabled and set to report all errors.
Placing the following code at the top of your PHP files (or in a master configuration file) will enable error reporting.
error_reporting(-1);
ini_set('display_errors', 'On');
set_error_handler("var_dump");
2- Check your server's mail logs.
(you may need to ask your server administrator where they are located) but they can commonly be found in a user's root directory under logs.
3- Check to see if mail() returns true or false.
The mail() function:
Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
This is important to note because:
If you receive a FALSE return value you know the error lies with your server accepting your mail. This probably isn't a coding issue but a server configuration issue. You need to speak to your system administrator to find out why this is happening.
If your receive a TRUE return value it does not mean your email will definitely be sent. It just means the email was sent to its respective handler on the server successfully by PHP. There are still more points of failure outside of PHP's control that can cause the email to not be sent.
So FALSE will help point you in the right direction whereas TRUE does not necessarily mean your email was sent successfully.
4- Check your spam folders / Prevent your email from being flagged as spam.
5- Make sure you supply mail headers.
$header = "From: noreply@example.com\r\n";
$header.= "MIME-Version: 1.0\r\n";
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header.= "X-Priority: 1\r\n";
6- end to multiple accounts.
To help rule out email account issues.
7- Consider using an alternative mailer.
PHP's built in mail() function is handy and often gets the job done. But there are alternatives that offer more power and flexibility including handling a lot of the issues outlined above. One that would might consider using is the popular PHPMailer